I’m trying to register distinct button presses from different joysticks i have plugged in, but somehow the code i have acts as though the buttons of all joysticks are being pressed at once when any of them is pressed. I think I’m making a simple mistake somewhere:
Here’s how my inputs are set up: http://imgur.com/k6qMW
I have the following script attached to my camera in my otherwise empty scene:
function Update () {
var j=0;
while(j<3){
var f = Input.GetButtonDown("FireButton"+(j+1));
if(f){
Debug.Log("FireButton:"+(j+1));
}
j++;
}
}
What I was expecting is that when I pressed the first firebutton on my first joystick, i’d get a single log item: “FireButton:1”. But instead I get three items printed to the console: “FireButton:1”, “FireButton:2”, “FireButton:3” and I’m not understanding why. Can anyone point out where I’m going wrong here?