How to handle a Microsoft Controller? C#
Hey,
I have two more or less identical characters in my scene. I can switch between them with...
private GameObject Character1;
private GameObject Character2;
void Start () {
Character1 = GameObject.Find("Character1");
Character2 = GameObject.Find("Character2");
Character1.SetActive (true);
Character2.SetActive(false);
}
void Update()
{
if (Input.GetKeyDown (KeyCode.Mouse0)) {
Character2.SetActive(true);
Character1.SetActive(false);
}
if (Input.GetKeyDown (KeyCode.Mouse1)) {
Character2.SetActive(false);
Character1.SetActive(true);
}
}
}
Everything worked fine and I could control both characters with the keyboard. But then I connected a Microsoft Controller. Without doing anything I can control Character1 but when I switch to Character2 I can’t control him.
The Problem is: I don´t know why I’m able to control Character1 with the MS Controller in the first place.
Any idea what happened and why I can control one but not the other?
$$anonymous$$icrosoft controller? XBox360? XBone? XBox Elite?
Anyways, how are you controlling? By using Input axes? By polling Input?
If you're using Input, you'll have to check for $$anonymous$$eyCode.JoystickButtonX, not $$anonymous$$ouseX. What Joystick button is where on a controller changes between every single controller, just to make things complicated.
Your answer
Follow this Question
Related Questions
fps script not working 1 Answer
Help on how to code crouching? 0 Answers
The code does not work in unity 0 Answers
Character Controller can accelerate but cant deccelerate 1 Answer