VR¶
System · VR · server and client scripts
VR reads headset and motion controller poses, velocities, analog inputs, and session state on the local client, and queues controller haptics and play-space recentering. It works in client scripts only.
Enabled¶
Enabled is true while an XR session is active on this client.
Default false
Errors (1)
| Error | When |
|---|---|
Enabled can only be written from a client script |
Written from a server script. |
SessionState¶
SessionState is the current lifecycle state of the XR session ("Off", "Idle", "Ready", "Synchronized", "Visible", "Focused", "Stopping", "LossPending", or "Exiting").
Default "Off"
Errors (1)
| Error | When |
|---|---|
SessionState can only be written from a client script |
Written from a server script. |
HeadScale¶
HeadScale multiplies every position returned by Pose in units and scales stereo view separation around the play-space origin.
Default 1
Errors (1)
| Error | When |
|---|---|
HeadScale can only be written from a client script |
Written from a server script. |
Pose¶
Pose returns the device position in play-space units, its orientation as a Rotation, and whether the device currently has a valid tracked pose.
Example
Errors (1)
| Error | When |
|---|---|
Pose can only be called from a client script |
Called from a server script. |
Velocity¶
Velocity returns the linear velocity of device in units per second, or nil when unavailable.
Errors (1)
| Error | When |
|---|---|
Velocity can only be called from a client script |
Called from a server script. |
AngularVelocity¶
AngularVelocity returns the angular velocity of device in degrees per second, or nil when unavailable.
Errors (1)
| Error | When |
|---|---|
AngularVelocity can only be called from a client script |
Called from a server script. |
IsTracked¶
IsTracked returns true when device ("Head", "LeftHand", "RightHand", "LeftAim", or "RightAim") has a valid tracked pose this frame.
Errors (1)
| Error | When |
|---|---|
IsTracked can only be called from a client script |
Called from a server script. |
Thumbstick¶
Thumbstick returns the 2D deflection of the controller thumbstick for hand ("Left" or "Right") as a Vector2.
Example
Errors (1)
| Error | When |
|---|---|
Thumbstick can only be called from a client script |
Called from a server script. |
Trigger¶
Trigger returns the analog index trigger pull from 0 to 1 for hand.
Example
Errors (1)
| Error | When |
|---|---|
Trigger can only be called from a client script |
Called from a server script. |
Squeeze¶
Squeeze returns the analog grip squeeze from 0 to 1 for hand.
Example
Errors (1)
| Error | When |
|---|---|
Squeeze can only be called from a client script |
Called from a server script. |
Recenter¶
Recenter requests a play-space recenter so the player's current head position and horizontal yaw become the play-space origin facing -Z.
Errors (1)
| Error | When |
|---|---|
Recenter can only be called from a client script |
Called from a server script. |
Vibrate¶
Vibrate queues a haptic vibration pulse on hand ("Left" or "Right").
Errors (1)
| Error | When |
|---|---|
Vibrate can only be called from a client script |
Called from a server script. |
StateChanged¶
StateChanged fires with the new SessionState string whenever the XR session changes state.
Example
Errors (1)
| Error | When |
|---|---|
StateChanged can only be written from a client script |
Written from a server script. |
TrackingChanged¶
TrackingChanged fires with (device, tracked) whenever a VR device gains or loses pose tracking.
Example
Errors (1)
| Error | When |
|---|---|
TrackingChanged can only be written from a client script |
Written from a server script. |
Recentered¶
Recentered fires when the play-space origin resets after Recenter or a headset system recenter.
Errors (1)
| Error | When |
|---|---|
Recentered can only be written from a client script |
Written from a server script. |