{"_id":"594949e62be16d0026ec04f4","category":{"_id":"594949e62be16d0026ec04d8","version":"594949e52be16d0026ec04cd","project":"571fa55ca0acd42000af9545","__v":0,"sync":{"url":"","isSync":false},"reference":false,"createdAt":"2017-01-01T16:58:11.374Z","from_sync":false,"order":10,"slug":"presence","title":"Presence"},"user":"571fa519db52d01700f5cf3d","parentDoc":null,"project":"571fa55ca0acd42000af9545","version":{"_id":"594949e52be16d0026ec04cd","project":"571fa55ca0acd42000af9545","__v":2,"createdAt":"2017-06-20T16:14:29.816Z","releaseDate":"2017-06-20T16:14:29.816Z","categories":["594949e62be16d0026ec04ce","594949e62be16d0026ec04cf","594949e62be16d0026ec04d0","594949e62be16d0026ec04d1","594949e62be16d0026ec04d2","594949e62be16d0026ec04d3","594949e62be16d0026ec04d4","594949e62be16d0026ec04d5","594949e62be16d0026ec04d6","594949e62be16d0026ec04d7","594949e62be16d0026ec04d8","594949e62be16d0026ec04d9","594949e62be16d0026ec04da","594949e62be16d0026ec04db","594949e62be16d0026ec04dc","594949e62be16d0026ec04dd","594949e62be16d0026ec04de","594949e62be16d0026ec04df","594949e62be16d0026ec04e0","594949e62be16d0026ec04e1","59497219f4a8980024dd0631"],"is_deprecated":false,"is_hidden":false,"is_beta":false,"is_stable":true,"codename":"Kunekune","version_clean":"3.2.0","version":"3.2.0"},"__v":0,"updates":[],"next":{"pages":[],"description":""},"createdAt":"2017-01-01T16:59:29.533Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[]},"settings":"","auth":"required","params":[],"url":""},"isReference":false,"order":7,"body":"## Overview\n\nThe Position Rewind script is used to reset the user back to a good known standing position upon receiving a headset collision event.\n\n## Inspector Parameters\n\n * **Collision Detector:** The colliders to determine if a collision has occured for the rewind to be actioned.\n * **Ignore Trigger Colliders:** If this is checked then the collision detector will ignore colliders set to `Is Trigger = true`.\n * **Rewind Delay:** The amount of time from original headset collision until the rewind to the last good known position takes place.\n * **Pushback Distance:** The additional distance to push the play area back upon rewind to prevent being right next to the wall again.\n * **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.\n * **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.\n * **Target List Policy:** A specified VRTK_PolicyList to use to determine whether any objects will be acted upon by the Position Rewind.\n * **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.\n * **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.\n\n## Class Variables\n\n * `public enum CollisionDetectors` - Valid collision detectors.\n  * `HeadsetOnly` - Listen for collisions on the headset collider only.\n  * `BodyOnly` - Listen for collisions on the body physics collider only.\n  * `HeadsetAndBody` - Listen for collisions on both the headset collider and body physics collider.\n\n## Class Events\n\n * `PositionRewindToSafe` - Emitted when the draggable item is successfully dropped.\n\n## Unity Events\n\nAdding the `VRTK_PositionRewind_UnityEvents` component to `VRTK_PositionRewind` object allows access to `UnityEvents` that will react identically to the Class Events.\n\n * All C# delegate events are mapped to a Unity Event with the `On` prefix. e.g. `MyEvent` -> `OnMyEvent`.\n\n## Event Payload\n\n * `Vector3 collidedPosition` - The position of the play area when it collded.\n * `Vector3 resetPosition` - The position of the play area when it has been rewinded to a safe position.\n\n## Class Methods\n\n### SetLastGoodPosition/0\n\n  > `public virtual void SetLastGoodPosition()`\n\n  * Parameters\n   * _none_\n  * Returns\n   * _none_\n\nThe SetLastGoodPosition method stores the current valid play area and headset position.\n\n### RewindPosition/0\n\n  > `public virtual void RewindPosition()`\n\n  * Parameters\n   * _none_\n  * Returns\n   * _none_\n\nThe RewindPosition method resets the play area position to the last known good position of the play area.\n\n## Example\n\n`VRTK/Examples/017_CameraRig_TouchpadWalking` has the position rewind script to reset the user's position if they walk into objects.","excerpt":"","slug":"vrtk_positionrewind","type":"basic","title":"VRTK_PositionRewind"}

VRTK_PositionRewind


## Overview The Position Rewind script is used to reset the user back to a good known standing position upon receiving a headset collision event. ## 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 ### SetLastGoodPosition/0 > `public virtual void SetLastGoodPosition()` * Parameters * _none_ * Returns * _none_ The SetLastGoodPosition method stores the current valid play area and headset position. ### RewindPosition/0 > `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. ## Example `VRTK/Examples/017_CameraRig_TouchpadWalking` has the position rewind script to reset the user's position if they walk into objects.