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

FirstPersonLocomotor Class

Extends MonoBehaviour
This locomotion handler will respond to locomotion events by moving a CharacterController and keep it in sync with the VR player (represented by its root transform and the center eye transform).
Appart from the locomotion event types it can also react to external calls for jumping, crouching or running. Velocity is applied during Update, but other Locomotion events are not applied instantly, instead they are collected and applied all once at the end of the frame to avoid desyncs between interactions.
Translation events: LocomotionEvent.Translation.Velocity: will add to the current velocity of the character and a delta will be applied every update to the capsule, checking for collisions and also dampening the velocity along time. LocomotionEvent.Translation.Relative: will move the character in the requested direction by also checking for collisions. LocomotionEvent.Translation.Absolute: will move the character's feet to the requested position while trying to snap it to the ground if found under the requested pose. LocomotionEvent.Translation.AbsoluteEyeLevel: will move the character so it's head ends up placed at the requested pose (not the feet). By doing this the capsule can potentially become missaligned with the ground so physics will be disabled until a new event is registered, the player physically moves _exitHotspotDistance or EnableMovement is called manually.
Rotation events: LocomotionEvent.Rotation.Velocity: will rotate the character by this angular velocity using the provided delta time. LocomotionEvent.Rotation.Absolute: will force the character to face the requested absolute rotation. LocomotionEvent.Rotation.Relative: will force the character to rotate the requested amount.
Other behaviors: When Player transforms are provided, the height of the capsule will stay in sync with the actual player height (distance from the top of their head to their floor). When the character and player transforms differ more than _maxWallPenetrationDistance, the player will instantly be teleported to the character position if an input is registered. This can be manually controller by calling ResetPlayerToCharacter manually.

Protected Fields

_started : bool
Signature
bool Oculus.Interaction.Locomotion.FirstPersonLocomotor._started
_whenLocomotionEventHandled : Action< LocomotionEvent, Pose >
Signature
Action<LocomotionEvent, Pose> Oculus.Interaction.Locomotion.FirstPersonLocomotor._whenLocomotionEventHandled

Fields

IgnoringVelocity : bool
Velocity movements can be disabled either by calling DisableMovement or teleporting to a Hostpot that sets the Head (instead of the feet) to a specific pose.
Signature
bool Oculus.Interaction.Locomotion.FirstPersonLocomotor.IgnoringVelocity
IsCrouching : bool
Indicates whether the character is crouching
Signature
bool Oculus.Interaction.Locomotion.FirstPersonLocomotor.IsCrouching
IsGrounded : bool
Indicates whether the character was detected as grounded after the last move.
Signature
bool Oculus.Interaction.Locomotion.FirstPersonLocomotor.IsGrounded
IsRunning : bool
Indicates whether the character is running
Signature
bool Oculus.Interaction.Locomotion.FirstPersonLocomotor.IsRunning

Properties

Acceleration : float
[Get][Set]
Signature
float Oculus.Interaction.Locomotion.FirstPersonLocomotor.Acceleration
AirDamping : float
[Get][Set]
Signature
float Oculus.Interaction.Locomotion.FirstPersonLocomotor.AirDamping
AutoUpdateHeight : bool
[Get][Set]
Signature
bool Oculus.Interaction.Locomotion.FirstPersonLocomotor.AutoUpdateHeight
CoyoteTime : float
[Get][Set]
Signature
float Oculus.Interaction.Locomotion.FirstPersonLocomotor.CoyoteTime
CrouchHeightOffset : float
[Get][Set]
Signature
float Oculus.Interaction.Locomotion.FirstPersonLocomotor.CrouchHeightOffset
CrouchSpeedFactor : float
[Get][Set]
Signature
float Oculus.Interaction.Locomotion.FirstPersonLocomotor.CrouchSpeedFactor
DefaultHeight : float
[Get][Set]
Signature
float Oculus.Interaction.Locomotion.FirstPersonLocomotor.DefaultHeight
ExitHotspotDistance : float
[Get][Set]
Signature
float Oculus.Interaction.Locomotion.FirstPersonLocomotor.ExitHotspotDistance
FlattenInputVelocity : bool
[Get][Set]
Signature
bool Oculus.Interaction.Locomotion.FirstPersonLocomotor.FlattenInputVelocity
GravityFactor : float
[Get][Set]
Signature
float Oculus.Interaction.Locomotion.FirstPersonLocomotor.GravityFactor
GroundDamping : float
[Get][Set]
Signature
float Oculus.Interaction.Locomotion.FirstPersonLocomotor.GroundDamping
HeightOffset : float
[Get][Set]
Signature
float Oculus.Interaction.Locomotion.FirstPersonLocomotor.HeightOffset
InputVelocityStabilization : AnimationCurve
[Get][Set]
Signature
AnimationCurve Oculus.Interaction.Locomotion.FirstPersonLocomotor.InputVelocityStabilization
JumpDamping : float
[Get][Set]
Signature
float Oculus.Interaction.Locomotion.FirstPersonLocomotor.JumpDamping
JumpForce : float
[Get][Set]
Signature
float Oculus.Interaction.Locomotion.FirstPersonLocomotor.JumpForce
MaxWallPenetrationDistance : float
[Get][Set]
Signature
float Oculus.Interaction.Locomotion.FirstPersonLocomotor.MaxWallPenetrationDistance
RunningSpeedFactor : float
[Get][Set]
Signature
float Oculus.Interaction.Locomotion.FirstPersonLocomotor.RunningSpeedFactor
SpeedFactor : float
[Get][Set]
Signature
float Oculus.Interaction.Locomotion.FirstPersonLocomotor.SpeedFactor
Velocity : Vector3
[Get][Set]
The current Velocity of the Locomotor.
Use the setter with caution, a LocomotionEvent of type Velocity is the preferred way of influencing the velocity of the character
Signature
Vector3 Oculus.Interaction.Locomotion.FirstPersonLocomotor.Velocity
WhenLocomotionEventHandled : Action< LocomotionEvent, Pose >
Signature
Action<LocomotionEvent, Pose> Oculus.Interaction.Locomotion.FirstPersonLocomotor.WhenLocomotionEventHandled

Protected Methods

LastUpdate ()
Signature
virtual void Oculus.Interaction.Locomotion.FirstPersonLocomotor.LastUpdate()
Returns
void
LateUpdate ()
Signature
virtual void Oculus.Interaction.Locomotion.FirstPersonLocomotor.LateUpdate()
Returns
void
OnDisable ()
Signature
virtual void Oculus.Interaction.Locomotion.FirstPersonLocomotor.OnDisable()
Returns
void
OnEnable ()
Signature
virtual void Oculus.Interaction.Locomotion.FirstPersonLocomotor.OnEnable()
Returns
void
Start ()
Signature
virtual void Oculus.Interaction.Locomotion.FirstPersonLocomotor.Start()
Returns
void
Update ()
Signature
virtual void Oculus.Interaction.Locomotion.FirstPersonLocomotor.Update()
Returns
void

Methods

Crouch ( crouch )
When true, it will enable crouching by applying the crouch height offset to the character and using the crouch speed factor for movement
Signature
void Oculus.Interaction.Locomotion.FirstPersonLocomotor.Crouch(bool crouch)
Parameters
crouch: bool  True to crouch, false to stand up
Returns
void
DisableMovement ()
Disables grounding and velocity movements.
Preventing the character from catching up to the player, sliding or falling.
Signature
void Oculus.Interaction.Locomotion.FirstPersonLocomotor.DisableMovement()
Returns
void
EnableMovement ()
Re-enables movement if it was disabled.
Making sure grounding is working again.
Signature
void Oculus.Interaction.Locomotion.FirstPersonLocomotor.EnableMovement()
Returns
void
HandleLocomotionEvent ( locomotionEvent )
Processes an incoming locomotion event and applies the appropriate transformations or state changes based on the event type.
Signature
void Oculus.Interaction.Locomotion.FirstPersonLocomotor.HandleLocomotionEvent(LocomotionEvent locomotionEvent)
Parameters
locomotionEvent: LocomotionEvent  The LocomotionEvent containing movement or teleportation data
Returns
void
InjectAllFirstPersonLocomotor ( characterController , playerEyes , playerOrigin )
Signature
void Oculus.Interaction.Locomotion.FirstPersonLocomotor.InjectAllFirstPersonLocomotor(CharacterController characterController, Transform playerEyes, Transform playerOrigin)
Parameters
characterController: CharacterController
playerEyes: Transform
playerOrigin: Transform
Returns
void
InjectCharacterController ( characterController )
Signature
void Oculus.Interaction.Locomotion.FirstPersonLocomotor.InjectCharacterController(CharacterController characterController)
Parameters
characterController: CharacterController
Returns
void
InjectOptionalContext ( context )
Signature
void Oculus.Interaction.Locomotion.FirstPersonLocomotor.InjectOptionalContext(Context context)
Parameters
context: Context
Returns
void
InjectOptionalMaxStartGroundDistance ( maxStartGroundDistance )
Signature
void Oculus.Interaction.Locomotion.FirstPersonLocomotor.InjectOptionalMaxStartGroundDistance(float maxStartGroundDistance)
Parameters
maxStartGroundDistance: float
Returns
void
InjectPlayerEyes ( playerEyes )
Signature
void Oculus.Interaction.Locomotion.FirstPersonLocomotor.InjectPlayerEyes(Transform playerEyes)
Parameters
playerEyes: Transform
Returns
void
InjectPlayerOrigin ( playerOrigin )
Signature
void Oculus.Interaction.Locomotion.FirstPersonLocomotor.InjectPlayerOrigin(Transform playerOrigin)
Parameters
playerOrigin: Transform
Returns
void
Jump ()
Jump vertically if it the character grounded.
If the character is crouching it will stand up instead.
Signature
void Oculus.Interaction.Locomotion.FirstPersonLocomotor.Jump()
Returns
void
ResetPlayerToCharacter ()
Instantly moves the Player to the character position
Signature
void Oculus.Interaction.Locomotion.FirstPersonLocomotor.ResetPlayerToCharacter()
Returns
void
Run ( run )
When true, it will enable running by applying the running speed factor to the movement
Signature
void Oculus.Interaction.Locomotion.FirstPersonLocomotor.Run(bool run)
Parameters
run: bool
Returns
void
SetDeltaTimeProvider ( deltaTimeProvider )
Sets a custom function that returns the last delta time in seconds.
Signature
void Oculus.Interaction.Locomotion.FirstPersonLocomotor.SetDeltaTimeProvider(Func< float > deltaTimeProvider)
Parameters
deltaTimeProvider: Func< float >  A delegate that returns the time elapsed since the last frame.
Returns
void
SetTimeProvider ( timeProvider )
Sets a custom function that provides the current time in seconds.
Signature
void Oculus.Interaction.Locomotion.FirstPersonLocomotor.SetTimeProvider(Func< float > timeProvider)
Parameters
timeProvider: Func< float >  A delegate that returns the current time in seconds.
Returns
void
ToggleCrouch ()
If the character is crouching it will stand up and vice versa
Signature
void Oculus.Interaction.Locomotion.FirstPersonLocomotor.ToggleCrouch()
Returns
void
ToggleRun ()
If the character is walking it will run and vice versa
Signature
void Oculus.Interaction.Locomotion.FirstPersonLocomotor.ToggleRun()
Returns
void