VRPlayerController

csharp
public class VRPlayerController : MonoBehaviour, IPlayerController

Namespace NodeWorld.SDK.Client.XR.

The local player's rig: the XR origin, its character controller and gravity, its avatar, seated mode, freezing, teleports and respawn.

Constants

DefaultRespawnHeight

csharp
public const float DefaultRespawnHeight = -200f

Respawn height of a world that does not set one (NWWorldRef).

Properties

RespawnHeight

csharp
public float RespawnHeight { get; set; }

Under this height (world y) the player comes back to its respawn point; set by the client for each world (NWWorldRef).

OriginVelocity

csharp
public Vector3 OriginVelocity { get; }

The rig's velocity this frame, smoothed, in meters per second.

YawDelta

csharp
public float YawDelta { get; }

How much the body turned this frame toward the head's heading, in degrees.

BodyForward

csharp
public Vector3 BodyForward { get; }

The body's forward direction on the ground plane.

BodyRight

csharp
public Vector3 BodyRight { get; }

The body's right direction on the ground plane.

BodyYaw

csharp
public float BodyYaw { get; }

The body's heading, in degrees.

IsGrounded

csharp
public bool IsGrounded { get; }

The character controller stands on the ground.

ActiveAvatar

csharp
public global::NWAvatar ActiveAvatar { get; }

The local player's avatar, or null.

ActiveViewpointHeight

csharp
public float ActiveViewpointHeight { get; }

Height of the active avatar's viewpoint above its root, in meters.

CurrentHMDHeight

csharp
public float CurrentHMDHeight { get; }

Height of the headset above the floor of the rig, in meters.

BodyHeight

csharp
public float BodyHeight { get; }

Height of the body: the headset's, or the avatar's viewpoint in seated mode.

HeightRatio

csharp
public float HeightRatio { get; }

BodyHeight relative to the calibrated height.

IsSeated

csharp
public bool IsSeated { get; }

Seated mode is on: the view is raised to the avatar's standing eye height.

IsFrozen

csharp
public bool IsFrozen { get; }

The player is frozen: no movement, no collisions.

GroundPosition

csharp
public Vector3 GroundPosition { get; }

The point on the ground under the body.

BodyCenter

csharp
public Vector3 BodyCenter { get; }

The center of the body at ground height.

HipPosition

csharp
public Vector3 HipPosition { get; }

Where the hips are, estimated from the head and the body.

NeckPosition

csharp
public Vector3 NeckPosition { get; }

Where the neck is, estimated from the head.

LeanOffset

csharp
public Vector3 LeanOffset { get; }

How far the head leans out of the body, on the ground plane.

Methods

SetRespawnPoint

csharp
public void SetRespawnPoint(Vector3 position, Quaternion rotation)

Sets where the player comes back to (the world's spawn point).

Respawn

csharp
public void Respawn()

Brings the player back to the respawn point.

RespawnFromMenu

csharp
public void RespawnFromMenu()

The respawn the player asks for in the client's menu (the dock's Respawn, Shift+R): what the world imposed on the player (NWPlayerControls: immobilized, speeds, gravity, a velocity, a seat) is undone first, then the player is back at the respawn point (plan Flux B3, « Respawn et Quitter marchent toujours »). The world hears it as any respawn (Respawned), and may set its own settings again then.

SetActiveAvatar

csharp
public void SetActiveAvatar(global::NWAvatar avatar)

Makes avatar the local player's avatar.

ClearActiveAvatar

csharp
public void ClearActiveAvatar()

Removes the local player's avatar.

ValidateCameraViewpointAlignment

csharp
public void ValidateCameraViewpointAlignment(global::NWAvatar avatar, float tolerance = 0.01f)

Throws when the camera is farther than tolerance meters from avatar's viewpoint.

EnableSeatedMode

csharp
public void EnableSeatedMode()

Seated mode: the view is raised to the avatar's eye height while the player sits.

DisableSeatedMode

csharp
public void DisableSeatedMode()

Back to standing: the view follows the headset's real height.

Freeze

csharp
public void Freeze()

Stops the player: no movement and no collisions, until Unfreeze.

Unfreeze

csharp
public void Unfreeze()

Lets the player move again after Freeze.

TeleportTo

csharp
public void TeleportTo(Vector3 position, Quaternion rotation)

Moves the player to position, facing rotation, upright.

TeleportTilted

csharp
public void TeleportTilted(Vector3 position, Quaternion rotation)

As TeleportTo, the play space tilted to rotation: a seat that pitches and rolls with a vehicle (FL# Player.Teleport with a rotation). The view tilts with it; TeleportTo and Respawn set it upright again.

Events

Respawned

csharp
public static event Action Respawned

The local player was brought back to its respawn point (fell under the respawn height, or Respawn).