Skip to content

Commit

Permalink
fix(Controller): calculate velocity correctly on play area rotation
Browse files Browse the repository at this point in the history
Previously, if the play area was rotated then the reported velocity
received from the Controller Events script was incorrect as it was
affected by the rotation of the play area. This fix ensures the
velocity reported is purely based on the controller.
  • Loading branch information
thestonefox committed Aug 25, 2016
1 parent 62bed52 commit b3b9f75
Showing 1 changed file with 2 additions and 14 deletions.
16 changes: 2 additions & 14 deletions Assets/VRTK/Scripts/VRTK_ControllerEvents.cs
Expand Up @@ -718,20 +718,8 @@ private void Update()

private void SetVelocity()
{
var origin = VRTK_DeviceFinder.TrackedObjectOrigin(gameObject);
var velocity = VRTK_SDK_Bridge.GetVelocityOnIndex(controllerIndex);
var angularVelocity = VRTK_SDK_Bridge.GetAngularVelocityOnIndex(controllerIndex);

if (origin != null)
{
controllerVelocity = origin.TransformDirection(velocity);
controllerAngularVelocity = origin.TransformDirection(angularVelocity);
}
else
{
controllerVelocity = velocity;
controllerAngularVelocity = angularVelocity;
}
controllerVelocity = VRTK_SDK_Bridge.GetVelocityOnIndex(controllerIndex); ;
controllerAngularVelocity = VRTK_SDK_Bridge.GetAngularVelocityOnIndex(controllerIndex); ;
}
}
}

0 comments on commit b3b9f75

Please sign in to comment.