Input
Input is managed by the AvatarInput
component attached to the avatar prefab. This component utilizes ‘input providers’ to ensure compatibility across multiple build targets, including screen space experiences. When the application starts or the input context changes (e.g. a new headset is detected), the AvatarInput
component will cycle through the list of input providers and use the first one that is compatible.
Events are available for each input on both the left and right controllers. These events are used in the provided avatar prefab to enable all aspects of its functionality. You can add your own event handlers to these inputs or modify them to customize the controls for your app.
The primary input provider is the Unity XR Input Provider, designed specifically for XR-based input. The main configurable option for this provider is the input offset asset, which allows you to apply positional and rotational offsets to the input values before they are sent to the AvatarInput
.
Action | Input |
---|---|
Grab | Grip |
Teleport | Thumbstick forward |
Turn | Thumbstick left/right |
UI Interact | Trigger |
You can adjust the threshold for the thumbstick to be considered a ‘press’ by modifying the ‘Axis Threshold’ setting.
For non-XR applications, the Screen Space Input Provider is included. This enables users without a headset to navigate and interact with the environment using mouse input. Although this cannot provide the full XR experience, it is great for simple experiences or inviting more users to a multiplayer session.
With the Screen Space Input Provider, you can also configure the avatar height and hand positions.