The XR Interaction Toolkit package provides a set of locomotion primitives that offer the means to move around in a scene during an XR experience. These components include:
Update
This documentation outlines how to use and extend these components.
ArchitectureThe main components of the locomotion architecture are the Locomotion Mediator, the various Locomotion Providers, the XR Body Transformer, and the Body Transformations which are applied to the XR Body Transformer by the Locomotion Providers.
Locomotion Providers contain a reference to the Locomotion Mediator, and the Locomotion Mediator in turn provides the Locomotion Providers with access to the XR Body Transformer. The Locomotion Mediator also maintains the Locomotion State for the Locomotion Providers making transformation requests.
The Locomotion Providers calculate the appropriate transformation and upon receiving access to the XR Body Transformer, the provider attempts to queue the Body Transformation with the XR Body Transformer.
The XR Body Transformer queues the transformation and applies each transformation to the XR Movable Body on Update
.
The overall flow of a Locomotion request is as follows:
Update
, the XR Body Transformer applies each transformation that is queued.The XR Origin is available for transformation in a container class called XRMovableBody
. The XR Movable Body can be transformed using the user's body as a frame of reference.
The XR Movable Body is a container for the XR Origin that can be transformed using the user's body as a frame of reference. The XR Movable Body contains a reference to an XR Origin and the XR Origin transform and is instantiated by the XR Body Transformer.
Additionally, the XR Movable body utilizes a Body Position Evaluator, which determines the position of the user's body, and a Constrain Manipulator, which can be used to perform movement that is constrained by collision.
Locomotion MediatorThe Locomotion Mediator component is a key part of locomotion, mediating transformation requests from Locomotion Providers, giving Locomotion Providers access to the XR Body Transformer, and managing the Locomotion State of the Locomotion Providers.
The Locomotion Mediator gets the XR Body Transformer component on Awake
to prepare for Locomotion Provider requests.
When Locomotion Providers call LocomotionMediator.TryPrepareLocomotion
, the Locomotion Mediator will add the Locomotion Provider to a provider data map for future processing and update the Locomotion Provider's Locomotion State to LocomotionState.Preparing
in the data map. Once the provider is in LocomotionState.Preparing
the Locomotion Mediator will transition the provider to LocomotionState.Moving
during the next LocomotionMediator.Update
where LocomotionProvider.canStartMoving
is true.
Similarly, when Locomotion Providers call LocomotionMediator.TryStartLocomotion
, the Locomotion Mediator will add the Locomotion Provider to a provider data map for future processing and update the Locomotion Provider's Locomotion State to Locomotion.Moving
in the data map. The Locomotion Mediator will then call LocomotionProvider.OnLocomotionStart(IXRBodyTransformer)
to grant that Provider access to the XR Body Transformer. Note, LocomotionMediator.TryStartLocomotion
is usually called from LocomotionMediator.TryStartLocomotionImmediately
, which will bypass the LocomotionState.Preparing
state and not check LocomotionProvider.canStartMoving
.
Lastly, when the locomotion is complete, the Locomotion Providers call LocomotionMediator.TryEndLocomotion
. The Locomotion Mediator will check if the Locomotion State of that provider is still active. If it is no longer active, the Locomotion Mediator will update the Locomotion Provider's Locomotion State to LocomotionState.Ended
and calls LocomotionProvider.OnLocomotionEnd()
on the locomotion provider.
Locomotion State is a replacement for the deprecated Locomotion Phase. It represents the state of locomotion for any given Locomotion Provider.
Property Description Idle Locomotion state where the Locomotion Provider is idle, before locomotion input occurs. Preparing Locomotion state where the Locomotion Provider is getting ready to move, when locomotion start input occurs. Moving Locomotion state where the Locomotion Provider is queuing XR Body Transformations with the XR Body Transformer. Ended Locomotion state where the Locomotion Provider is no longer moving, after locomotion end input has completed. XR Body TransformerThe XR Body Transformer component manages user locomotion via transformations of an XR Origin.
Locomotion Providers that have gained access to the XR Body Transformer via the Locomotion Mediator can call XRBodyTransformer.QueueTransformation(IXRBodyTransformation)
to queue the transformation to be applied next Update
. Transformations are applied sequentially based on ascending priority and transformations with the same priority are applied in the order they were queued. Each transformation is removed from the queue after it is applied.
IXRBodyTransformation
is an interface for a transformation that can be applied to an XR Origin using the user's body as a frame of reference. The following classes are the current implementations of IXRBodyTransformation
:
The Gravity Provider is a locomotion provider that provides gravity to the player. This provider will also check if the player is grounded by using a sphere cast from the player's head in the direction gravity is being applied, either absolute or relative to the player. Gravity will be applied to the player anytime useGravity
is true and isGrounded
is false. See IGravityController
for external control over gravity.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4