-2
\$\begingroup\$

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.

\$\endgroup\$
  • \$\begingroup\$ Xbox 360 controller. also would helpful to know how to set up right koystick to look around with fps controller \$\endgroup\$ – The MattBat999 Aug 20 '16 at 17:10
  • 1
    \$\begingroup\$ I'm not sure what you mean by "the rest of the internet". I found the answer on the first result from typing "unity xbox controller" into Google. Been using that reference for about a year, now, and confirmed it is still accurate before posting it as an answer. \$\endgroup\$ – Gnemlock Aug 21 '16 at 1:27
0
\$\begingroup\$
  • Go to "Devices and Printers" in the system settings (this is found at different places in different versions of Windows)
  • Right-click on the gamepad and select "Game Controller Settings"
  • Click "Properties"

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.

\$\endgroup\$
  • \$\begingroup\$ I've got that, but how do you actually USE it in with fire1 and 2? \$\endgroup\$ – The MattBat999 Aug 20 '16 at 17:40
  • \$\begingroup\$ This interface is helpful, but it appears to be purposed more towards testing that the controller is functional, and as such, there are a few discrepancies between how it interprets the controller, and how unity interprets the controller. For example, there is no "rotation" axis in unity, and the buttons in unity start counting at 0, as opposed to 1. More specific to the point of this question, while the Game Controller window reports the trigger as "Axis Z", unity interprets it as "Axis 3" or "Axis 9" and "Axis 10", depending on how you implement it. \$\endgroup\$ – Gnemlock Aug 21 '16 at 1:32
3
\$\begingroup\$

Below is a helpful image guide, provided by the Unify Community Wiki article on the Xbox 360 controller.

A picture of an Xbox 360 controller, with all axis labelled relative to a Windows system.

Make sure you use Axis

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" - 0 or 1.

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 Input.GetKey(KeyCode).

Using both triggers for a single axis

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.

Using individual axis to represent each trigger

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.

Operating system does make a substantial difference

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.

Mac OSX

Mac OSX Xbox 360 button mapping using the Tattie Bogle driver.

Linux

Linux Xbox 360 button mapping

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.

\$\endgroup\$
0
\$\begingroup\$

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()

https://docs.unity3d.com/ScriptReference/Input.GetAxis.html

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.

\$\endgroup\$
  • \$\begingroup\$ You can also configure the triggers as buttons if you so choose. \$\endgroup\$ – DMGregory Dec 29 '18 at 18:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.