- Home /
How do I get my Xbox One controller to work with my mini game in Unity?
I am aware of the Input Manager but besides that I am unsure if there has to be any code that must be written. I just want to be able to assign the controls I have to my controller and have them working.
First please do not keep on posting the same question, we will just reject them! Can you post a pic of your Input Settings(Inspector View), and your scripts that handle the movement that you want the Xbox Controller to handle. Thanks.
For some reason the site won't let me upload the pictures I took.
But
On my Input $$anonymous$$anager I have:
Name: ControllerAttack1P Positive Button: joystick button 0 Gravity:1000 Dead: 0.001 Sensitivity: 1000 Type: $$anonymous$$ey or $$anonymous$$ouse button Axis: X axis Joy Num: Get motion from all joysticks
The code I am trying to get to work is:
if (Input.GetButtonDown ("ControllerAttack1P")) { if(special == 5){ specialAttack (); special = 0; Input.GetAxis("ControllerAttack1P"); } }
Ok, if it is a button, which it looks like it is then try this :
if (Input.GetButtonDown("ControllerAttack1P")) {
Debug.Log("A Button pressed");
}
$$anonymous$$ake sure this is being run in Update() not FixedUpdate() and let me know if the message is displayed in the Debug Window when you press "A" on the controller.
You use GetAxis for the Thumbsticks and the Trigger inputs only.
Ok I wrote the code like that and the Debug Window did display the message "A button pressed".
Then your controller and input settings are working fine. It is something in the rest of your code that is preventing this from working how you want it to. As a starter for finding out use this :
if (Input.GetButtonDown("ControllerAttack1P")) {
Debug.Log("A Button pressed");
if (special == 5) {
Debug.Log("special does = 5");
//Put Debug Statements in the function you
//call here to see what is and is not being
//run.
specialAttack();
special = 0;
}
}
Then continue to narrow down where the problem is via the Debug.Log method. You should be able to find out where it is going wrong, if you don't(after you have had a good try) then post your full script with the issue as a new question. Thanks!
Answer by Pflobus · Dec 07, 2014 at 11:03 PM
There is another way. At least, I tried it with my PS3 controller, and a program called something like DS3 Controller. If I were you, and I wanted to switch the keycodes, or translate those keycodes (WASD) to the Xbox One controller, I would hook up the controller, because I think it should come with some charging cable, and if possible, use it with the computer. Then, just look up a 3rd party software. But I'm not sure about the Xbox One. I hope this helped :)