XBOX360 Controller Triggers refuse to cooperate

First time posting, wassup unity folk.

I have been through every post I could find in reference to the 360 inputs. I cannot get the triggers to register. They show up in the Joystick and Gamepad Tester as a Z axis / Z rotation.

I have them set in the input window on the 5th and 6th axis. 20 inputs

Gravity = 0, Dead = 0.17, Sensitivity = 1

I am using the tattiebogle 360 controller driver 0.06, and have been installing and uninstalling the different versions to see if that was the problem, but no luck.

Anyone who has actually gotten the triggers to work, I would greatly appreciate any assist. I gotta flash background so real code is slow going for a pixel pushin pimp like myself. Thanks - Ez.

Hi,

The trick to the Xbox 360 triggers is that they aren’t read as buttons, but as Axes.

So, to get the right trigger to work, for example, you use these settings in the input manager:

Type: Joystick Axis
Axis: 6th Axis (Joysticks)

Then to get the data from the trigger use Input.GetAxis instead of Input.GetButton.

The surprising thing to me is that the triggers only return a 1 or 0 (unless I’m doing something wrong).

I hope that helps! It’s working great for me with tattiebogle 0.06.

-A

FYI: The buttons and axes for the controller can be found here:
http://forum.unity3d.com/viewtopic.php?t=14162&highlight=xbox+360+joystick

Thanks very much for the assistance A, I did have a question. I swapped :

if (canJump Input.GetButton(“Old_Jump”)) {

with

if (canJump Input.GetAxis(“Right Trigger”)) {

and get this error:

Assets/Character Controller Scripts/NormalCharacterMotor.cs(58,25): error CS0029: Cannot implicitly convert type float' to bool’

I haven’t played with the axis, but I’m assuming:

Get Button returned a 1 or 0, or true /false

Get Axis is returning 1.0 or 0.0, a float.

Try casting get.Axis as an int or bool and see if it works.
I know this isn’t the proper way, but just to demonstrate:

(int)Input.GetAxis(“Right Trigger”)

or test for a value,

… Input.GetAxis(“Right Trigger”) > 0.0f ) {

You need to test to see if the axis value !=0 (or actually 0.5 I think, haven’t messed with the 360 controller in a while). doesn’t work with non boolean values, so you do the != or > or <, etc to get a boolean value first.

thanks alot

I just went through tonight with a 360 controller, and I came up with a ‘chart’ mapping the Input Manager settings to controller inputs. Hopefully someone finds it slightly useful :smile:

XBox 360 Button Settings
D-Pad Up = 5
D-Pad Down = 6
D-Pad Left = 7
D-Pad Right = 8
Start = 9
Back = 10
Left Stick Click = 11
Right Stick Click = 12
Left Bumper = 13
Right Bumper = 14
Guide = 15
A = 16
B = 17
X = 18
Y = 19

Axis #s

Left Stick Horizontal = 1 (X Axis in Input Manager)
Left Stick Vertical = 2 (Y Axis in Input Manager)
Right Stick Horizontal = 3
Right Stick Vertical = 4
Left Trigger = 5
Right Trigger = 6

I have written a very simple app which displays all the joystick inputs being received

here it is

http://www.rotorheadgame.com/unity/joytest.html

it gives:
For a Mac

Left X : x Axis
Left Y : y Axis
Right X : 3rd Axis
Right Y : 4th Axis
Left Trig : 5th Axis
Right Trig : 6th Axis
D-pad Up : 5
D-pad Down : 6
D-pad Left : 7
D-pad Right : 8
Start : 9
Back : 10
Left Stick Click : 11
Right Click Click : 12
LB : 13
RB : 14
A : 16
B : 17
X : 18
Y : 19

For a PC

Left X : x Axis
Left Y : y Axis
Right X : 4th Axis
Right Y : 5th Axis
Left Trig : +ve 3rd Axis
Right Trig : -ve 3rd Axis
D-pad Up : +ve 7th Axis
D-pad Down : -ve 7th Axis
D-pad Left : -ve 6th Axis
D-pad Right : +ve 6th Axis
Start : 7
Back : 6
Left Stick Click : 8
Right Click Click : 9
LB : 4
RB : 5
A : 0
B : 1
X : 2
Y : 3

on the mac using Colin Munro 's 360 controller driver version 0.06.

http://tattiebogle.net/ (under projects)
http://mice-software.com/

I found this post very helpful, thank you!

I’m having trouble rotating an object based on the analog sticks.

I want a game object to point its Z rotation in the same direction as a player is pointing the right stick.

I’ve got as far as getting an angle reading from the pad, from 0 through to 359, but applying it to transform.rotation.z makes the object flip around wildly.

Can anyone help?

Thanks,

James

sokay, got it sorted - never touch rotation.x,y,z directly unless you eat Quaternions for breakfast.

Foder - this is wonderul…

Would you mind posting the source?

Sean

Foder - this is wonderul…

Would you mind posting the source?

Sean