Skip to content

Commit

Permalink
feat(Presence): add toggle to reset position on headset collision
Browse files Browse the repository at this point in the history
A new parameter has been added to the Player Presence script to
determine if the CameraRig position should be reset to a good known
position if the user's headset collides with another game object.

It is now possible with the `resetPositionOnCollision` parameter to
determine whether this action of position reset happens or not.
  • Loading branch information
thestonefox committed Jun 26, 2016
1 parent c7dbc55 commit 04e571f
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
Binary file not shown.
3 changes: 2 additions & 1 deletion Assets/SteamVR_Unity_Toolkit/Scripts/VRTK_PlayerPresence.cs
Expand Up @@ -7,6 +7,7 @@ public class VRTK_PlayerPresence : MonoBehaviour
{
public float headsetYOffset = 0.2f;
public bool ignoreGrabbedCollisions = true;
public bool resetPositionOnCollision = true;

private Transform headset;
private Rigidbody rb;
Expand Down Expand Up @@ -58,7 +59,7 @@ private void OnUngrabObject(object sender, ObjectInteractEventArgs e)

private void OnHeadsetCollision(object sender, HeadsetCollisionEventArgs e)
{
if (lastGoodPositionSet)
if (resetPositionOnCollision && lastGoodPositionSet)
{
SteamVR_Fade.Start(Color.black, 0f);
this.transform.position = lastGoodPosition;
Expand Down
7 changes: 7 additions & 0 deletions README.md
Expand Up @@ -579,6 +579,13 @@ The following script parameters are available:
box collider and rigid body on the play area. This is very useful
if the user is required to grab and wield objects because if the
collider was active they would bounce off the play area collider.
* **Reset Position On Collision:** If this is checked then if the
Headset Collision Fade script is present and a headset collision
occurs, the Camera Rig is moved back to the last good known
standing position. This deals with any collision issues if a user
stands up whilst moving through a crouched area as instead of them
being able to clip into objects they are transported back to a
position where they are able to stand.

An example of the `VRTK_PlayerPresence` script can be viewed in
the scene `SteamVR_Unity_Toolkit/Examples/017_CameraRig_TouchpadWalking`.
Expand Down

0 comments on commit 04e571f

Please sign in to comment.