Xbox Controller and Input.GetButtonDown( );

Hey there,

I’ve searched around for this problem and couldn’t find anything on this particular issue so sorry for a dupe if this is one.

However, in our game when getting the controller input everything works perfectly as long as the method is Input.GetButton. However, if the method is changed to Input.GetButtonDown() it suddenly stops working.

As sample of our code:

    public void Update( )
    {
        bool test = Input.GetButtonDown( "EBrake_1" );
        if( test )
        {
            Debug.Log( "Get Key Working" );
        }
    }

And the working code:

    public void Update( )
    {
        bool test = Input.GetButton( "EBrake_1" );
        if( test )
        {
            Debug.Log( "Get Key Working" );
        }
    }

I’m not too sure what the issue is, I’ve tried storing them in variables, calling them directly, etc. The only thing I can think of is that the GetButtonDown method doesn’t work with xbox one controller.

Make two boolean variables set to false. On the first frame Button is detected make the A boolean true. Detect this condition, including that the other, B, is false. After this make B = A;

3 Answers

3

Probably too late to reply, but I just tried changing my Input in input Manager to “Key or Mouse Button” instead of “Joystick Axis” and it works like a charm. :smiley:

Well you just saved my life, I just went crazy because it worked with controller 1 and 2 but not with 3

thank you.

http://wiki.unity3d.com/index.php?title=Xbox360Controller

And use Input.GetKeyDown("joystick button 0")

Yea that works fine, I'll just use that. But it does bother me a bit that the GetButtonDown doesn't work? Seems like a bug in Unity itself? In any case we will just use that. Thank you!

if anyone still has the same problem
just follow this wiki http://wiki.unity3d.com/index.php?title=Xbox360Controller
edit > project settings > input > then follow the instructions from the site.