Skip to content

Commit 97f55a5

Browse files
authored
Merge pull request #190 from smallrice45/patch-1
Update ControllerInteraction.cs
2 parents 2a1d623 + 47a1837 commit 97f55a5

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

Packages/webxr-interactions/Runtime/Scripts/ControllerInteraction.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ public class ControllerInteraction : MonoBehaviour
4545
private string loadedHandProfile = null;
4646
private Dictionary<int, Transform> handModelJoints = new Dictionary<int, Transform>();
4747
private static Quaternion quat180 = Quaternion.Euler(0, 180, 0);
48+
49+
private Vector3 currentVelocity;
50+
private Vector3 previousPos;
4851
#endif
4952

5053
private void Awake()
@@ -283,7 +286,9 @@ private void OnHandUpdate(WebXRHandData handData)
283286
return;
284287
}
285288
Quaternion rotationOffset = Quaternion.Inverse(handData.joints[0].rotation);
286-
289+
currentVelocity = (transform.position - previousPos) / Time.deltaTime;
290+
previousPos = transform.position;
291+
287292
#if WEBXR_INPUT_PROFILES
288293
if (useInputProfile && loadedHandModel)
289294
{
@@ -512,7 +517,7 @@ public void Drop()
512517
{
513518
if (!currentRigidBody)
514519
return;
515-
520+
currentRigidBody.velocity = currentVelocity;
516521
attachJoint.connectedBody = null;
517522
currentRigidBody = null;
518523
}

0 commit comments

Comments
 (0)