The GetAnalog
method retrieves the current value of a specified analog input. This method is useful for obtaining the state of analog controls such as joysticks or triggers on a game controller.
The GetAnalog
method retrieves the current value of a specified analog input. This method is useful for obtaining the state of analog controls such as joysticks or triggers on a game controller.
To use the GetAnalog
method, pass in the desired InputAnalog
enumeration value that corresponds to the analog input you wish to query. The method returns a float
representing the current state of the analog input, typically ranging from -1.0 to 1.0.
// Example of using GetAnalog to get the state of the left thumbstick's horizontal axis float leftThumbstickX = Input.GetAnalog(InputAnalog.LeftThumbstickX); // Check if the thumbstick is being pushed to the right if (leftThumbstickX > 0.5f) { // Perform action when thumbstick is pushed right }