GetGamepadState
For thread safety, this property is not safe to read in an unsynchronized thread.
This function returns an array of InputObject|InputObjects
for all available inputs on the given Enum/UserInputType
gamepad, representing each input’s last input state.
To find the Enum/UserInputType|UserInputTypes
of connected gamepads, use UserInputService/GetConnectedGamepads
.
As this function only fires locally, it can only be used in a LocalScript
.
See this page for articles on cross-platform development.
See also
UserInputService/GamepadConnected
UserInputService/GamepadDisconnected
UserInputService/GetConnectedGamepads
UserInputService/GetNavigationGamepads
UserInputService/SetNavigationGamepad
UserInputService/IsNavigationGamepad
UserInputService/IsGamepadButtonDown
UserInputService/GetSupportedGamepadKeyCodes
UserInputService/GetGamepadConnected
UserInputService/GamepadSupports
UserInputService/GamepadEnabled
Parameters
Name | Type | Default | Description |
---|---|---|---|
|
The |
Returns
Return Type | Summary |
---|---|
An array of |
Code Samples
Mapping and Polling GamepadStates
This example demonstrates how to map a Enum/UserInputType|gamepad’s
states to their corresponding Enum|KeyCode|KeyCodes
, and then you can always reference them. Since the states are mutable; you don’t have to keep calling GetGamepadState once they are mapped. Then, you can reference the states of the gamepad’s controls using KeyCodes and indices - such as to poll the Thumbstick1 position.