text
stringlengths
0
1.11k
// returns true if the primary thumbstick is currently pressed (clicked as a button)
OVRInput.Get(OVRInput.Button.PrimaryThumbstick);
// returns true if the primary thumbstick has been moved upwards more than halfway.
// (Up/Down/Left/Right - Interpret the thumbstick as a D-pad).
OVRInput.Get(OVRInput.Button.PrimaryThumbstickUp);
// returns a float of the secondary (typically the Right) index finger trigger’s current state.
// (range of 0.0f to 1.0f)
OVRInput.Get(OVRInput.Axis1D.SecondaryIndexTrigger);
// returns a float of the left index finger trigger’s current state.
// (range of 0.0f to 1.0f)
OVRInput.Get(OVRInput.RawAxis1D.LIndexTrigger);
// returns true if the left index finger trigger has been pressed more than halfway.
// (Interpret the trigger as a button).
OVRInput.Get(OVRInput.RawButton.LIndexTrigger);
// returns true if the secondary gamepad button, typically “B”, is currently touched by the user.
OVRInput.Get(OVRInput.Touch.Two);
In addition to specifying a control, Get() also takes an optional controller parameter. The list of supported controllers is defined by the OVRInput.Controller enumeration (for details, refer to OVRInput in the Unity Scripting Reference guide.
Specifying a controller can be used if a particular control scheme is intended only for a certain controller type. If no controller parameter is provided to Get(), the default is to use the Active controller, which corresponds to the controller that most recently reported user input. For example, a user may use a pair of controllers, set them down, and pick up an Xbox controller, in which case the Active controller will switch to the Xbox controller once the user provides input with it. The current Active controller can be queried with OVRInput.GetActiveController() and a bitmask of all the connected Controllers can be queried with OVRInput.GetConnectedControllers().
Example Usage:
// returns a float of the hand trigger’s current state on the left controller.
OVRInput.Get(OVRInput.Axis1D.PrimaryHandTrigger, OVRInput.Controller.Touch);
// returns a float of the hand trigger’s current state on the right controller.
OVRInput.Get(OVRInput.Axis1D.SecondaryHandTrigger, OVRInput.Controller.Touch);
Note: Oculus Touch controllers can be specified either as the combined pair (with OVRInput.Controller.Touch), or individually (with OVRInput.Controller.LTouch and RTouch). This is significant because specifying LTouch or RTouch uses a different set of virtual input mappings that allow more convenient development of hand-agnostic input code.
Example Usage:
// returns a float of the hand trigger’s current state on the left controller.
OVRInput.Get(OVRInput.Axis1D.PrimaryHandTrigger, OVRInput.Controller.LTouch);
// returns a float of the hand trigger’s current state on the right controller.
OVRInput.Get(OVRInput.Axis1D.PrimaryHandTrigger, OVRInput.Controller.RTouch);
This can be taken a step further to allow the same code to be used for either hand by specifying the controller in a variable that is set externally, such as on a public variable in Unity Editor.
Example Usage:
// public variable that can be set to LTouch or RTouch in the Unity Inspector
public Controller controller;
// returns a float of the hand trigger’s current state on the controller
// specified by the controller variable.
OVRInput.Get(OVRInput.Axis1D.PrimaryHandTrigger, controller);
// returns true if the primary button (“A” or “X”) is pressed on the controller
// specified by the controller variable.
OVRInput.Get(OVRInput.Button.One, controller);
This is convenient since it avoids the common pattern of if/else checks for left or right hand input mappings.
Touch Input Mapping
The following diagrams illustrate common input mappings for the controllers. For more information on additional mappings that are available, refer to OVRInput in the Unity Scripting Reference guide.
Virtual Mapping (Accessed as a Combined Controller)
When accessing controllers as a combined pair with OVRInput.Controller.Touch, the virtual mapping closely matches the layout of a typical gamepad split across the left and right hands.
Virtual Mapping (Accessed as Individual Controllers)
When accessing the left or right controller individually with OVRInput.Controller.LTouch or OVRInput.Controller.RTouch, the virtual mapping changes to allow for hand-agnostic input bindings. For example, the same script can dynamically query the left or right controller depending on which hand it is attached to, and Button.One is mapped appropriately to either the A or X button.
Raw Mapping
The raw mapping directly exposes the controllers. The layout of the controllers closely matches the layout of a typical gamepad split across the left and right hands.Add Controller Animations
The platform for which this article is written (Unity) does not match your preferred platform (Nativa).
Haz clic aquí para ver la página del índice de la documentación para tu plataforma de preferencia.
Controller Animations
Meta XR Core SDK comes with controller animations for Meta headset controllers. Meta XR Core SDK is available individually or as part of the Meta XR All-in-One SDK with Unity Package Manager. The controller animations can be used whenever you don’t have custom models to represent controllers. They can also be used in tutorials to teach users how to interact with your app using their Meta controllers.
Controller Animations In A Game Tutorial
Let’s say you’re developing a racing game for Meta headsets. You can create a tutorial that teaches users how to open the door to their car, get inside the car, and grip the steering wheel before they begin driving around a track.
Open the Car Door
The player needs to hold the trigger grip and pull near the car door handle to open it.
The tutorial displays an overlay that says they need to press the trigger button to open the door.
The trigger button animation plays.
The player presses the trigger button and pulls the car door open.
Get Into the Car
The the player needs to get into the car.
The tutorial displays an overlay that says they need to press the B button to get in the car.
The B button controller animation plays.
The player presses the B button and gets into the their vehicle.
Grip the Steering Wheel
The player needs to hold both controllers and close their hands to grip the trigger.
The tutorial displays an overlay that says they need to press both grip trigger buttons to steer.
Both grip trigger animations play.
The player presses both grip trigger buttons.
Controller animations could be used to remind players of the correct buttons for actions like opening a car door in the game even after the tutorial.