Skip to content

Commit

Permalink
Additional adjustments to grip system.
Browse files Browse the repository at this point in the history
  • Loading branch information
rossTnick committed Oct 5, 2023
1 parent 4d1000d commit 62cf427
Show file tree
Hide file tree
Showing 6 changed files with 758 additions and 11 deletions.
9 changes: 7 additions & 2 deletions Assets/Code/Hands/GrabPose.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,18 @@ public class GrabPose : BatchedComponent {
public Grabber GrabbableBy;
public GameObject GrabberVisual;
public GameObject GrabberTracked;
public float GripAmount = 0.0f;
#endregion // Inspector

[NonSerialized] public bool IsGrabPosed = false;
[NonSerialized] public bool UsedGravity = false;
//[NonSerialized] public bool UsedGravity = false;

private void Awake() {

//set the grip parameter here...
Animator a = GetComponent<Animator>();
if(a != null) {
a.SetFloat(Animator.StringToHash("Flex"), GripAmount);
}
}
}
}
13 changes: 9 additions & 4 deletions Assets/Code/Hands/Grabbable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,8 @@ static public bool DropCurrent(Grabber grabber, bool applyReleaseForce) {
Assert.True(idx >= 0);
ArrayUtils.FastRemoveAt(grabber.Holding.CurrentGrabbers, ref grabber.Holding.CurrentGrabberCount, idx);

//grabber.Holding.CurrentGrabberCount--;

if(grabber.Holding != null) {
if(grabber.Holding.StayKinematic) {
if(grabber.Holding.LeftGrip != null) {
Expand Down Expand Up @@ -202,18 +204,21 @@ static public void GrabPoseOn(GrabPose gp, Grabbable grabbable) {
gp.GrabberVisual.SetActive(false);
gp.gameObject.SetActive(true);
gp.IsGrabPosed = true;
gp.UsedGravity = grabbable.Rigidbody.useGravity;
//gp.UsedGravity = grabbable.Rigidbody.useGravity;
grabbable.Rigidbody.useGravity = false;
grabbable.Rigidbody.isKinematic = true;
}

static public void GrabPoseOff(GrabPose gp, Grabbable grabbable) {
gp.GrabberVisual.SetActive(true);
gp.gameObject.SetActive(false);
gp.IsGrabPosed = false;
grabbable.gameObject.transform.SetParent(grabbable.OriginalParent);
grabbable.Rigidbody.useGravity = true;
grabbable.Rigidbody.isKinematic = false;
gp.IsGrabPosed = false;
//Debug.Log(grabbable.CurrentGrabberCount);
if(grabbable.CurrentGrabberCount == 0) {
grabbable.Rigidbody.useGravity = true;
grabbable.Rigidbody.isKinematic = false;
}
}

static public void ReturnToOriginalSpawnPoint(Grabbable component) {
Expand Down
8 changes: 4 additions & 4 deletions Assets/Models/LeftHandAnimatorGrip.controller
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,22 @@ AnimatorController:
m_AnimatorParameters:
- m_Name: Flex
m_Type: 1
m_DefaultFloat: 0
m_DefaultFloat: 0.1
m_DefaultInt: 0
m_DefaultBool: 0
m_Controller: {fileID: 9100000}
m_Controller: {fileID: 0}
- m_Name: Pose
m_Type: 3
m_DefaultFloat: 0
m_DefaultInt: 0
m_DefaultBool: 0
m_Controller: {fileID: 9100000}
m_Controller: {fileID: 0}
- m_Name: Pinch
m_Type: 1
m_DefaultFloat: 0
m_DefaultInt: 0
m_DefaultBool: 0
m_Controller: {fileID: 9100000}
m_Controller: {fileID: 0}
m_AnimatorLayers:
- serializedVersion: 5
m_Name: Flex Layer
Expand Down
Loading

0 comments on commit 62cf427

Please sign in to comment.