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.

Fields

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.
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.
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.
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.
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.
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.
Determines whether rotation will be applied in a single large "snap" (snap-rotating) as opposed to more slowly over time (continuous-rotating).
[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.
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.
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.
If true, tracking data from a child OVRCameraRig will update the direction of movement.
This capability is sometimes referred to as "head-oriented movement."
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.
If true, each OVRPlayerController will use the player's physical height.
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.
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.
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.
When true, user input will be applied to rotation.
Set this to false whenever the player controller needs to ignore input for rotation.
Rotation defaults to secondary thumbstick.
You can allow either here. Note that this won't behave well if EnableLinearMovement is true.

Events

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.
This event is raised immediately after the camera transform has been updated, but before movement is updated.
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.

Protected Fields

CharacterController Controller[Get]
OVRCameraRig CameraRig[Get]

Properties

float InitialYRotation[Get]

Protected Functions

virtual void UpdateController ( )

Member Functions

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.
Invoked by OVRCameraRig's UpdatedAnchors callback.
Allows the Hmd rotation to update the facing direction of the player (assuming HmdRotatesY is enabled).
Causes the player to jump, unless the Unity Controller associated with this instance has its isGrounded property set to true.
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.
Accessor for the move scale multiplier, populating that value into the ref float argument.
Parameters
moveScaleMultiplier
Move scale multiplier output argument
Setter for the move scale multiplier.
Parameters
moveScaleMultiplier
New move scale multiplier value
Accessor for the rotation scale multiplier, populating that value into the ref float argument.
Parameters
rotationScaleMultiplier
Rotation scale multiplier output argument
Setter for the rotation scale multiplier.
Parameters
rotationScaleMultiplier
New rotation scale multiplier value
Accessor for the "skip mouse rotation" setting, populating the value into the ref bool argument.
Parameters
skipMouseRotation
Skip mouse rotation output argument
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.
Parameters
skipMouseRotation
New setting for skipping mouse rotation
Accessor for the "halt update movement" setting, populating the value into the ref bool argument.
Parameters
haltUpdateMovement
Halt update movement output argument
Setter for the "halt update movement" setting, which determines whether user movement updating will be paused.
Parameters
haltUpdateMovement
New setting for halting the movement update
Resets the player look rotation when the device orientation is reset.
Did you find this page helpful?
Thumbs up icon
Thumbs down icon