- Home /
How to find joysticks axises?
Hi,
I am creating a radio controlled flight sim, nearly finished, see some info here if interested: http://forum.unity3d.com/threads/rc-flight-sim-project.289046/
With Radio control you get these usb transmitters, see pic below, which are essentially joysticks.
I can see that the joysticks are are detected but I am not sure what axies to define, how can I find out which joystick axis is what with a device such as this? Any help would be much appreciated!
I meant to say how to define these or know which joystick axies they are in the Unity Input manager area..
Answer by Mystigan · Jan 15, 2015 at 09:22 AM
Hey , I had the same issue with thrustmaster steering kit, After a bit of googling I stumbled on this Input Mapper master It worked for me maybe you can configure it for your controller as well :)
Cool, I have looked at that but have no idea yet on how detect what my device is setup as, hope I can understand... thanks for this.
Well , I had a look at your suggestion but seemed quite a lot to get into, I decided to debug my inputs and created a little test scene, then I mapped each axis one in some simple javascript by one until I had all correct, now I know what is what and I can use that in my real game. Thanks for the suggestion, much appreciated!
Answer by jrocamora · Aug 27, 2016 at 02:23 PM
setup every possible axis in the input manager as "axis 0", "axis 1", "axis 2", etc. and then use this code on an empty gameobject to find which one your hitting. it will show up in the console, and also be stored during runtime in the array which you can look at in the inspector
//these go up top
public bool recentered;
public string[] axes = new string[30];
public int n;
//start
n = 0;
//put this in your update
for (int i = 0; i < 30; i++) {
if (n == 0 || Input.GetAxis(axes [n - 1]) == 0) {
recentered = true;
}
if (Input.GetAxis ("axis " + i) != 0 && recentered) {
print("axis " + i);
recentered = false;
axes [n] = "axis " + i;
n++;
}
}