API reference

CapsuleLocomotionHandler Class

Extends MonoBehaviour
This locomotion handler will respond to locomotion events by moving a character represented as a CapsuleCollider 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. When moved using velocities, the character will collide with the world, preventing the capsule from penetrating through colliders or falling through the floor.
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 heigth increases it will also check for collisions above to avoid the character from clipping with low ceilings and other obstacles. When the character and player transforms difer 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. When moving using Translation.Velocity or Translation.Relative, if a collision against a wall is registered, the capsule will try to rebound and slide along it using _maxReboundSteps iterations.

Protected Fields

_started : bool
Signature
bool _started
_whenLocomotionEventHandled : Action< LocomotionEvent, Pose >
Signature
Action<LocomotionEvent, Pose> _whenLocomotionEventHandled

Properties

Acceleration : float
[Get][Set]
Signature
float Acceleration
AirDamping : float
[Get][Set]
Signature
float AirDamping
AutoUpdateHeight : bool
[Get][Set]
Signature
bool AutoUpdateHeight
CrouchHeightOffset : float
[Get][Set]
Signature
float CrouchHeightOffset
CrouchSpeedFactor : float
[Get][Set]
Signature
float CrouchSpeedFactor
DefaultHeight : float
[Get][Set]
Signature
float DefaultHeight
ExitHotspotDistance : float
[Get][Set]
Signature
float ExitHotspotDistance
GravityFactor : float
[Get][Set]
Signature
float GravityFactor
GroundDamping : float
[Get][Set]
Signature
float GroundDamping
HeightOffset : float
[Get][Set]
Signature
float HeightOffset
IsGrounded : bool
[Get]
Indicates wheter the character was detected as grounded after the last move.
Signature
bool IsGrounded
JumpDamping : float
[Get][Set]
Signature
float JumpDamping
JumpForce : float
[Get][Set]
Signature
float JumpForce
LayerMask : LayerMask
[Get][Set]
Signature
LayerMask LayerMask
MaxReboundSteps : int
[Get][Set]
Signature
int MaxReboundSteps
MaxSlopeAngle : float
[Get][Set]
Signature
float MaxSlopeAngle
MaxStep : float
[Get][Set]
Signature
float MaxStep
MaxWallPenetrationDistance : float
[Get][Set]
Signature
float MaxWallPenetrationDistance
RunningSpeedFactor : float
[Get][Set]
Signature
float RunningSpeedFactor
SkinWidth : float
[Get][Set]
Signature
float SkinWidth
SpeedFactor : float
[Get][Set]
Signature
float SpeedFactor
WhenLocomotionEventHandled : Action< LocomotionEvent, Pose >
Signature
Action<LocomotionEvent, Pose> WhenLocomotionEventHandled

Protected Methods

LastUpdate ()
Signature
virtual void LastUpdate()
Returns
void
LateUpdate ()
Signature
virtual void LateUpdate()
Returns
void
OnDisable ()
Signature
virtual void OnDisable()
Returns
void
OnEnable ()
Signature
virtual void OnEnable()
Returns
void
Start ()
Signature
virtual void Start()
Returns
void
Update ()
Signature
virtual void 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 Crouch(bool crouch)
Parameters
crouch: bool  True to crouch, false to stand up
Returns
void
DisableMovement ()
Disables grounding until a new input is requested or the movement is manually re-enabled.
Signature
void DisableMovement()
Returns
void
EnableMovement ()
Re-enables movement if it was disabled.
Making sure grounding is working again
Signature
void EnableMovement()
Returns
void
HandleLocomotionEvent ( locomotionEvent )
Signature
void HandleLocomotionEvent(LocomotionEvent locomotionEvent)
Parameters
locomotionEvent: LocomotionEvent
Returns
void
InjectAllCapsuleLocomotionHandler ( capsule )
Signature
void InjectAllCapsuleLocomotionHandler(CapsuleCollider capsule)
Parameters
capsule: CapsuleCollider
Returns
void
InjectCapsule ( capsule )
Signature
void InjectCapsule(CapsuleCollider capsule)
Parameters
capsule: CapsuleCollider
Returns
void
Jump ()
Jump vertically if it the character grounded.
If the character is crouching it will stand up instead.
Signature
void Jump()
Returns
void
ResetPlayerToCharacter ()
Instantly moves the Player to the character position.
Signature
void ResetPlayerToCharacter()
Returns
void
Run ( run )
When true, it will enable running by applying the running speed factor to the movement.
Signature
void Run(bool run)
Parameters
run: bool
Returns
void
SetDeltaTimeProvider ( deltaTimeProvider )
Sets a function that returns the last delta time in seconds.
Signature
void SetDeltaTimeProvider(Func< float > deltaTimeProvider)
Parameters
deltaTimeProvider: Func< float >
Returns
void
ToggleCrouch ()
If the character is crouching it will stand up and vice versa.
Signature
void ToggleCrouch()
Returns
void
ToggleRun ()
If the character is walking it will run and vice versa.
Signature
void ToggleRun()
Returns
void