Skip to content

Commit

Permalink
fix(Interaction): set precise spring anchor
Browse files Browse the repository at this point in the history
if attach mechanic is set to Spring Joint and snap type is set to
Precision Snap, set the anchor of the temporary SpringJoint to
controllerAttachPoint's current position in the grabbed object's space
  • Loading branch information
clydeshaffer committed Jun 22, 2016
1 parent 7632514 commit cce8dd1
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion Assets/SteamVR_Unity_Toolkit/Scripts/VRTK_InteractGrab.cs
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,10 @@ private void CreateJoint(GameObject obj)
SpringJoint tempSpringJoint = obj.AddComponent<SpringJoint>();
tempSpringJoint.spring = objectScript.springJointStrength;
tempSpringJoint.damper = objectScript.springJointDamper;
if(objectScript.grabAttachMechanic == VRTK_InteractableObject.GrabSnapType.Precision_Snap)
{
tempSpringJoint.anchor = obj.transform.InverseTransformPoint(controllerAttachPoint.position);
}
controllerAttachJoint = tempSpringJoint;
}
controllerAttachJoint.breakForce = objectScript.detachThreshold;
Expand Down Expand Up @@ -408,4 +412,4 @@ private void Update()
}
}
}
}
}

0 comments on commit cce8dd1

Please sign in to comment.