Common input tasks
Find the instructions for common input tasks, grouped by topic.
Read input from devices
- Check whether the user pressed a key or button this frame
- Check whether the user pressed any key or button
- Get the mouse or pointer position
- Get all current touches from the touchscreen
- Detect which GameObject the user clicks or touches
Find and manage devices
- Find all connected gamepads
- Find the device a player is using, for example to show matching button prompts
- Find out when the user connects or disconnects a device
- Add a deadzone to gamepad sticks
- Check which devices are connected, and their state
Set up actions and bindings
- Create a simple action, such as Fire. Use the same technique as the Jump action.
- Make an action trigger only after the user holds a button for some time
- Use a positive and a negative button to drive an axis
- Let players rebind their controls
- Display the name or icon of the control bound to an action
Create custom devices and layouts
- Create your own custom device
- Handle gamepad data in a format different from
GamepadState - Use your own layout when the native backend discovers a specific device
Work with XR devices
- Target or swap the left-hand and right-hand XR controllers
- Give head tracking an extra update before rendering