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

FirstPersonLocomotor Class

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.

Properties

float MaxWallPenetrationDistance[Get]
float ExitHotspotDistance[Get]
bool AutoUpdateHeight[Get]
float DefaultHeight[Get]
float HeightOffset[Get]
float CrouchHeightOffset[Get]
float SpeedFactor[Get]
float CrouchSpeedFactor[Get]
float RunningSpeedFactor[Get]
float Acceleration[Get]
float GroundDamping[Get]
float JumpDamping[Get]
float AirDamping[Get]
float JumpForce[Get]
float GravityFactor[Get]
bool FlattenInputVelocity[Get]
AnimationCurve InputVelocityStabilization[Get]
Action< LocomotionEvent, Pose > WhenLocomotionEventHandled

Protected Fields

Action< LocomotionEvent, Pose > _whenLocomotionEventHandled[Get]
bool _started[Get]

Fields

Indicates whether the character was detected as grounded after the last move.
Indicates whether the character is running
Indicates whether the character is crouching
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.

Member Functions

Sets a custom function that returns the last delta time in seconds.
Parameters
deltaTimeProvider
A delegate that returns the time elapsed since the last frame.
Jump vertically if it the character grounded.
If the character is crouching it will stand up instead.
If the character is crouching it will stand up and vice versa
When true, it will enable crouching by applying the crouch height offset to the character and using the crouch speed factor for movement
Parameters
crouch
True to crouch, false to stand up
If the character is walking it will run and vice versa
When true, it will enable running by applying the running speed factor to the movement
Parameters
run
Disables grounding and velocity movements.
Preventing the character from catching up to the player, sliding or falling.
Re-enables movement if it was disabled.
Making sure grounding is working again.
Instantly moves the Player to the character position
Processes an incoming locomotion event and applies the appropriate transformations or state changes based on the event type.
Parameters
locomotionEvent
The LocomotionEvent containing movement or teleportation data
Quaternion FlattenForwardOffset
( Quaternion rotation )
void InjectAllFirstPersonLocomotor
( CharacterController characterController,
Transform playerEyes,
Transform playerOrigin )
void InjectCharacterController
( CharacterController characterController )
void InjectPlayerEyes
( Transform playerEyes )
void InjectPlayerOrigin
( Transform playerOrigin )

Protected Functions

virtual void Start ( )
virtual void OnEnable ( )
virtual void OnDisable ( )
virtual void Update ( )
virtual void LateUpdate ( )
virtual void LastUpdate ( )
Did you find this page helpful?
Thumbs up icon
Thumbs down icon