API reference
API reference
Select your platform
No SDKs available
No versions available

OVRPlayerController Class

Extends MonoBehaviour
Controls the player's movement in virtual reality.
Specifically, this class builds on the functionality of Unity's built-in CharacterController type to permit movement paradigms suitable for virtual reality, such as teleportation. These capabilities are leveraged by OVRSceneSampleController to control functionality in the sample.

Protected Fields

CameraRig : OVRCameraRig
Signature
OVRCameraRig CameraRig
Controller : CharacterController
Signature
CharacterController Controller

Fields

Acceleration : float
Controls the rate of acceleration during continuous movement (as opposed to teleportation).
Well-tuned movement settings in VR play a significant role in user comfort and should be adjusted carefully. For more information, see Locomotion Best Practices.
Signature
float Acceleration
BackAndSideDampen : float
Controls the rate of additional damping when moving sideways or backwards during continuous movement (as opposed to teleportation).
Well-tuned movement settings in VR play a significant role in user comfort and should be adjusted carefully.
Signature
float BackAndSideDampen
CameraHeight : float
The CameraHeight is the actual height of the HMD and can be used to adjust the height of the character controller, which will affect the ability of the character to move into areas with a low ceiling.
Signature
float CameraHeight
Damping : float
Controls the rate of damping during continuous movement (as opposed to teleportation).
Well-tuned movement settings in VR play a significant role in user comfort and should be adjusted carefully.
Signature
float Damping
EnableLinearMovement : bool
When true, user input will be applied to linear movement.
Set this to false whenever the player controller needs to ignore input for linear movement.
Signature
bool EnableLinearMovement
EnableRotation : bool
When true, user input will be applied to rotation.
Set this to false whenever the player controller needs to ignore input for rotation.
Signature
bool EnableRotation
FixedSpeedSteps : int
Sets the number of discrete speeds that will be used in continuous motion.
If 0, motion speed is not discretized.
Well-tuned movement settings in VR play a significant role in user comfort and should be adjusted carefully.
Signature
int FixedSpeedSteps
GravityModifier : float
Modifies the strength of gravity.
This value does not set gravity, but merely modifies it. The underlying value used for gravity is retrieved from Unity's Physics system.
Signature
float GravityModifier
HmdResetsY : bool
If true, reset the initial yaw of the player controller when the Hmd pose is recentered.
Enabling this feature allows users to change the real-to-virtual spatial correspondence with respect to orientation changing how "north" in the virtual world corresponds with "north" in the real world, for example.
Signature
bool HmdResetsY
HmdRotatesY : bool
If true, tracking data from a child OVRCameraRig will update the direction of movement.
This capability is sometimes referred to as "head-oriented movement."
Signature
bool HmdRotatesY
JumpForce : float
Controls the force applied to the character when jumping.
Well-tuned movement settings in VR play a significant role in user comfort and should be adjusted carefully.
Signature
float JumpForce
RotateAroundGuardianCenter : bool
[Deprecated] When enabled, snap rotation will happen about the guardian rather than the player/camera viewpoint.
This (legacy) option should be left off except for edge cases that require extreme behavioral backwards compatibility.
Signature
bool RotateAroundGuardianCenter
RotationAmount : float
Controls the rate of rotation when continuous-rotating (as opposed to snap-rotating) using a gamepad.
If SnapRotation is enabled, RotationRatchet is used instead.
Well-tuned movement settings in VR play a significant role in user comfort and should be adjusted carefully.
Signature
float RotationAmount
RotationEitherThumbstick : bool
Rotation defaults to secondary thumbstick.
You can allow either here. Note that this won't behave well if EnableLinearMovement is true.
Signature
bool RotationEitherThumbstick
RotationRatchet : float
Controls the rate of rotation when turning using the keyboard.
Well-tuned movement settings in VR play a significant role in user comfort and should be adjusted carefully.
Signature
float RotationRatchet
SnapRotation : bool
Determines whether rotation will be applied in a single large "snap" (snap-rotating) as opposed to more slowly over time (continuous-rotating).
Signature
bool SnapRotation
Teleported : bool
This bool is set to true whenever the player controller has been teleported.
It is reset after every frame. Some systems, such as CharacterCameraConstraint, test this boolean in order to disable logic that moves the character controller immediately following the teleport.
Signature
bool Teleported
useProfileData : bool
If true, each OVRPlayerController will use the player's physical height.
Signature
bool useProfileData

Properties

InitialYRotation : float
[Get]
Signature
float InitialYRotation

Events

CameraUpdated : Action
This event is raised immediately after the camera transform has been updated, but before movement is updated.
Signature
Action CameraUpdated
PreCharacterMove : Action
This event is raised right before the character controller is actually moved in order to provide other systems the opportunity to move the character controller in response to things other than user input, such as movement of the HMD.
See CharacterCameraConstraint.cs for an example of this.
Signature
Action PreCharacterMove
TransformUpdated : Action< Transform >
This event is raised after the character controller is moved.
This is used by the OVRAvatarLocomotion script to keep the avatar transform synchronized with the OVRPlayerController.
Signature
Action<Transform> TransformUpdated

Protected Methods

UpdateController ()
Signature
virtual void UpdateController()
Returns
void

Methods

GetHaltUpdateMovement ( haltUpdateMovement )
Accessor for the "halt update movement" setting, populating the value into the ref bool argument.
Signature
void GetHaltUpdateMovement(ref bool haltUpdateMovement)
Parameters
haltUpdateMovement: ref bool  Halt update movement output argument
Returns
void
GetMoveScaleMultiplier ( moveScaleMultiplier )
Accessor for the move scale multiplier, populating that value into the ref float argument.
Signature
void GetMoveScaleMultiplier(ref float moveScaleMultiplier)
Parameters
moveScaleMultiplier: ref float  Move scale multiplier output argument
Returns
void
GetRotationScaleMultiplier ( rotationScaleMultiplier )
Accessor for the rotation scale multiplier, populating that value into the ref float argument.
Signature
void GetRotationScaleMultiplier(ref float rotationScaleMultiplier)
Parameters
rotationScaleMultiplier: ref float  Rotation scale multiplier output argument
Returns
void
GetSkipMouseRotation ( skipMouseRotation )
Accessor for the "skip mouse rotation" setting, populating the value into the ref bool argument.
Signature
void GetSkipMouseRotation(ref bool skipMouseRotation)
Parameters
skipMouseRotation: ref bool  Skip mouse rotation output argument
Returns
void
Jump ()
Causes the player to jump, unless the Unity Controller associated with this instance has its isGrounded property set to true.
Signature
bool Jump()
Returns
bool
ResetOrientation ()
Resets the player look rotation when the device orientation is reset.
Signature
void ResetOrientation()
Returns
void
SetHaltUpdateMovement ( haltUpdateMovement )
Setter for the "halt update movement" setting, which determines whether user movement updating will be paused.
Signature
void SetHaltUpdateMovement(bool haltUpdateMovement)
Parameters
haltUpdateMovement: bool  New setting for halting the movement update
Returns
void
SetMoveScaleMultiplier ( moveScaleMultiplier )
Setter for the move scale multiplier.
Signature
void SetMoveScaleMultiplier(float moveScaleMultiplier)
Parameters
moveScaleMultiplier: float  New move scale multiplier value
Returns
void
SetRotationScaleMultiplier ( rotationScaleMultiplier )
Setter for the rotation scale multiplier.
Signature
void SetRotationScaleMultiplier(float rotationScaleMultiplier)
Parameters
rotationScaleMultiplier: float  New rotation scale multiplier value
Returns
void
SetSkipMouseRotation ( skipMouseRotation )
Setter for the "skip mouse rotation" setting, which determines whether mouse movement is excluded from turning logic.
Mouse rotation in VR can be extremely uncomfortable for users and is disabled by default.
Signature
void SetSkipMouseRotation(bool skipMouseRotation)
Parameters
skipMouseRotation: bool  New setting for skipping mouse rotation
Returns
void
Stop ()
Causes the player to immediately stop moving, losing all speed and inertia.
Stopping merely eliminates all ongoing motion and does not lock the player in place; motion can resume as early as the next update.
Signature
void Stop()
Returns
void
UpdateMovement ()
Performs the movement updates for this character controller.
This is a core part of the OVRPlayerController's update logic and should not be invoked directly.
Signature
virtual void UpdateMovement()
Returns
void
UpdateTransform ( rig )
Invoked by OVRCameraRig's UpdatedAnchors callback.
Allows the Hmd rotation to update the facing direction of the player (assuming HmdRotatesY is enabled).
Signature
void UpdateTransform(OVRCameraRig rig)
Parameters
Returns
void