Input.GetButtonDown("Jump") not working using Xbox 360 Controller

Hello,

I am thankful for being able to share information on such threads.

I am currently working on a double jump script for my 2 d character, which is just a cube for now.

The rigidbody physics (collision and gravity) are all functional. This is tested in my script by calls to OnCollisionEnter and OnCollisionExit.

I have defined within the same one class a function that increments a previously declared jump_number integer type variable (number of times jumped) for each successful button press, detected by Input.GetButtonDown(“Jump”).

I then use the stored value of jump_number in my conditional that determines whether the rigidbody has jumped once (jump_number = 1 in this case) and can therefore jump again, only if it is not grounded.

I started testing this at runtime using a keyboard and the space key (still using ButtonDown not GetKey methods). Although the script clearly needs work as my cube cannot stop jumping once in the air, the space key is still being registered. The main problem I am having is that none of my Xbox 360 controller buttons are being detected in Input.GetButtonDown for an identical script.

Project settings are set to go. I know this because Input.GetButton(“Jump”) works fine with button 0 on my 360 controller.

I greatly appreciate your help on this. Here is a copy of my code:

using UnityEngine;
using System.Collections;

public class ButtonDown : MonoBehaviour
{
	int jump_number;
	bool is_onground;
	
	void OnCollisionEnter()
	{
		jump_number = 0;
		is_onground = true;
	}
	
	void OnCollisionExit()
	{
		is_onground = false;
	}
	
	public int jump_track()
	{
		if (Input.GetButtonDown("Jump") == true)
		{
			++jump_number;
			Debug.Log(jump_number);
		}
		
		return jump_number;
	}
	
	void Update ()
	{	
		jump_track();
		
		if (is_onground == true)
		{
			if (Input.GetButtonDown("Jump") == true)
		    {
			    rigidbody.AddForce(new Vector3(0,2000.0f * Time.deltaTime,0), ForceMode.Impulse);
	        }
		}
		
		if (is_onground == false)
		{
			if (Input.GetButtonDown("Jump") == true && jump_number <= 2)
			{
			rigidbody.AddForce(new Vector3(0,2000.0f * Time.deltaTime,0), ForceMode.Impulse);
			}
				
			if (jump_number >= 2)
			{
				rigidbody.AddForce (new Vector3(0,0,0));
			}
		}
					
	}
};

Thank you for taking the time to read this

Ok, GetButtonDown is a function handled by unity, so what you have to do is go into Edit>Project Settings>Input, it’ll show a GUI in your inspector of all the different GetButton names. Open the tab labeled “Jump” and and the corrosponding joystick button you want to use as your alternate positive button. http://wiki.unity3d.com/index.php?title=Xbox360Controller that is a list of the corrosponding joystick buttons.

So for example, of you wanted to make “a” your jump button you’d add this: joystick button 0, as your alternate position button. Like so: http://puu.sh/4fRuf.png.

Same problem here!

This fixed it for me! One of my inputs was registered as a Joystick not a Key or Mouse button!