I can't get a clear answer on the rest of the internet. What are the joystick buttons for left and right triggers?
I'm on Windows, if it matters.
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It only takes a minute to sign up.Sign up to join this community
Now press the buttons on the gamepad. You will see the icon with the corresponding number light up in the "testing" window. The same window can also be used to identify any axial inputs of the controller.
Below is a helpful image guide, provided by the Unify Community Wiki article on the Xbox 360 controller.
The triggers are represented as axis, as opposed to buttons. This is because the triggers output a value based on how far down they have been pressed. A trigger can output a value of
0.5 if only half-way pressed, while a button can only interpret "on" or "off" -
For this reason, the triggers are referenced as "axis", and not as "buttons". Apart from the terminology difference, this means that you must set them up using
InputManager, as opposed to having the additional option of calling them through
As you can see, the triggers are associated with "3rd axis". This means that if you set up an axis in your
InputManager to use "3rd Axis (Joysticks and Scrollwheel)" for its
Axis and set the
Type to "Joystick Axis", the axis will output
1 when you hold the left trigger down, and output
-1 when you hold the right trigger down1.
The previously mentioned Wiki page also points us in the direction of using individual axis to represent the two triggers. You could alternativley use the above setup with "9th Axis" to represent the left trigger, and "10th Axis" to represent the right trigger. Both axis will output
1 when you press the trigger down.
You mention using Windows, but in effort to make this answer more useful to other users, its worth mentioning that the controller references are unique to the driver being used. Given that Microsoft made both Windows and Xbox 360, it is not surprising that the controllers are "plug and play". However, you might find the need to download a specific driver for use on a Mac or Linux operating system. Below are two more additional image guides provided by the Unify Community Wiki detailing the changes on these alternate operating systems.
If you find yourself using either of these operating systems, I implore you to read more on the page, as there are slight differences in how they interpret the controller. For example, Mac OSX interprets triggers differently, and Linux interprets the D pad differently depending on whether your using a wireless controller or a wired controller.
1 You would probably expect left to be +1 and right to be -1, but thats how it outputs to the debug when I tested the default axis setup.
The left and right tigers are not buttons, they are axis. You need to poll them regularly, probably once a frame, to see when they are moved/pressed. In Unity you needed to check when the axis hits whatever threshold you want it to be. You need to figure out what axis the triggers are in Unity and use Input.GetAxis()
It returns a float between 0 and 1, or -1 and 1. Figure out what value in that range works for you, and then trigger input off of that threshold.