Attempts to rewind the position of the play area to a last know valid position upon the headset collision event.

Required Components:

  • VRTK_BodyPhysics - A Body Physics script to manage the collisions of the body presence within the scene.
  • VRTK_HeadsetCollision - A Headset Collision script to determine when the headset is colliding with valid geometry.

Script Usage:

  • Place the VRTK_PositionRewind script on any active scene GameObject.

Inspector Parameters

  • Collision Detector: The colliders to determine if a collision has occured for the rewind to be actioned.
  • Ignore Trigger Colliders: If this is checked then the collision detector will ignore colliders set to Is Trigger = true.
  • Rewind Delay: The amount of time from original headset collision until the rewind to the last good known position takes place.
  • Pushback Distance: The additional distance to push the play area back upon rewind to prevent being right next to the wall again.
  • Crouch Threshold: The threshold to determine how low the headset has to be before it is considered the user is crouching. The last good position will only be recorded in a non-crouching position.
  • Crouch Rewind Threshold: The threshold to determind how low the headset can be to perform a position rewind. If the headset Y position is lower than this threshold then a rewind won't occur.
  • Target List Policy: A specified VRTK_PolicyList to use to determine whether any objects will be acted upon by the Position Rewind.
  • Body Physics: The VRTK Body Physics script to use for the collisions and rigidbodies. If this is left blank then the first Body Physics script found in the scene will be used.
  • Headset Collision: The VRTK Headset Collision script to use to determine if the headset is colliding. If this is left blank then the script will need to be applied to the same GameObject.

Class Variables

  • public enum CollisionDetectors - Valid collision detectors.
    • HeadsetOnly - Listen for collisions on the headset collider only.
    • BodyOnly - Listen for collisions on the body physics collider only.
    • HeadsetAndBody - Listen for collisions on both the headset collider and body physics collider.

Class Events

  • PositionRewindToSafe - Emitted when the draggable item is successfully dropped.

Unity Events

Adding the VRTK_PositionRewind_UnityEvents component to VRTK_PositionRewind object allows access to UnityEvents that will react identically to the Class Events.

  • All C# delegate events are mapped to a Unity Event with the On prefix. e.g. MyEvent -> OnMyEvent.

Event Payload

  • Vector3 collidedPosition - The position of the play area when it collded.
  • Vector3 resetPosition - The position of the play area when it has been rewinded to a safe position.

Class Methods


public virtual void SetLastGoodPosition()

  • Parameters
    • none
  • Returns
    • none

The SetLastGoodPosition method stores the current valid play area and headset position.


public virtual void RewindPosition()

  • Parameters
    • none
  • Returns
    • none

The RewindPosition method resets the play area position to the last known good position of the play area.


VRTK/Examples/017_CameraRig_TouchpadWalking has the position rewind script to reset the user's position if they walk into objects.