Guides
These docs are for v2.2.1. Click to read the latest docs for v3.3.0.

VRTK_PlayerPresence

Overview

The concept that the VR user has a physical in game presence which is accomplished by adding a collider and a rigidbody at the position the user is standing within their play area. This physical collider and rigidbody will prevent the user from ever being able to walk through walls or intersect other collidable objects. The height of the collider is determined by the height the user has the headset at, so if the user crouches then the collider shrinks with them, meaning it's possible to crouch and crawl under low ceilings.

Inspector Parameters

  • Headset Y Offset: The collider which is created for the user is set at a height from the user's headset position. If the collider is required to be lower to allow for room between the play area collider and the headset then this offset value will shorten the height of the generated collider.
  • Ignore Grabbed Collisions: If this is checked then any items that are grabbed with the controller will not collide with the player presence collider. 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 collider.
  • Reset Position On Collision: If this is checked then if the Headset Collision script is present and a headset collision occurs, the CameraRig 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.
  • Falling Physics Only: Only use physics when an explicit falling state is set.

Class Events

  • PresenceFallStarted - Emitted when a gravity based fall has started.
  • PresenceFallEnded - Emitted when a gravity based fall has ended.

Unity Events

Adding the VRTK_PlayerPresence_UnityEvents component to VRTK_PlayerPresence object allows access to UnityEvents that will react identically to the Class Events.

  • OnPresenceFallStarted - Emits the PresenceFallStarted class event.
  • OnPresenceFallEnded - Emits the PresenceFallEnded class event.

Event Payload

  • float fallDistance - The total height the player has dropped from a gravity based fall.

Class Methods

SetFallingPhysicsOnlyParams/1

public void SetFallingPhysicsOnlyParams(bool falling)

  • Parameters
  • bool falling - Toggle the physics falling on or off.
  • Returns
  • none

The SetFallingPhysicsOnlyParams method will toggle the fallingPhysicsOnly class state as well as enable or disable physics if needed.

IsFalling/0

public bool IsFalling()

  • Parameters
  • none
  • Returns
  • bool - Returns if the player is in a physics falling state or not.

The IsFalling method will return if the class is using physics based falling and is currently in a falling state.

StartPhysicsFall/1

public void StartPhysicsFall(Vector3 velocity)

  • Parameters
  • Vector3 velocity - The starting velocity to use at the start of a fall.
  • Returns
  • none

The StartPhysicsFall method initializes the physics based fall state, enable physics and send out the PresenceFallStarted event.

StopPhysicsFall/0

public void StopPhysicsFall()

  • Parameters
  • none
  • Returns
  • none

The StopPhysicsFall method ends the physics based fall state, disables physics and send out the PresenceFallEnded event.

Example

VRTK/Examples/017_CameraRig_TouchpadWalking has a collection of walls and slopes that can be traversed by the user with the touchpad but the user cannot pass through the objects as they are collidable and the rigidbody physics won't allow the intersection to occur.