Skip to content

Commit

Permalink
fix(Locomotion): set rotation before teleport
Browse files Browse the repository at this point in the history
If the rotation is set after the new teleport position
is set then the final position of the user is in the wrong
position especially if the headset compensation is on.

The fix is to ensure rotation is done before any new location
position is determined.
  • Loading branch information
thestonefox committed Jul 14, 2017
1 parent 62aa1e0 commit e2ae7a7
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Assets/VRTK/Scripts/Locomotion/VRTK_BasicTeleport.cs
Original file line number Diff line number Diff line change
Expand Up @@ -162,13 +162,13 @@ public virtual void ForceTeleport(Vector3 destinationPosition, Quaternion? desti
{
DestinationMarkerEventArgs teleportArgs = BuildTeleportArgs(null, destinationPosition, destinationRotation);
StartTeleport(this, teleportArgs);
Quaternion updatedRotation = SetNewRotation(destinationRotation);
CalculateBlinkDelay(blinkTransitionSpeed, destinationPosition);
Blink(blinkTransitionSpeed);
if (ValidRigObjects())
{
playArea.position = destinationPosition;
}
Quaternion updatedRotation = SetNewRotation(destinationRotation);
ProcessOrientation(this, teleportArgs, destinationPosition, updatedRotation);
EndTeleport(this, teleportArgs);
}
Expand Down Expand Up @@ -248,11 +248,11 @@ protected virtual void DoTeleport(object sender, DestinationMarkerEventArgs e)
if (enableTeleport && ValidLocation(e.target, e.destinationPosition) && e.enableTeleport)
{
StartTeleport(sender, e);
Quaternion updatedRotation = SetNewRotation(e.destinationRotation);
Vector3 newPosition = GetNewPosition(e.destinationPosition, e.target, e.forceDestinationPosition);
CalculateBlinkDelay(blinkTransitionSpeed, newPosition);
Blink(blinkTransitionSpeed);
Vector3 updatedPosition = SetNewPosition(newPosition, e.target, e.forceDestinationPosition);
Quaternion updatedRotation = SetNewRotation(e.destinationRotation);
ProcessOrientation(sender, e, updatedPosition, updatedRotation);
EndTeleport(sender, e);
}
Expand Down

0 comments on commit e2ae7a7

Please sign in to comment.