Hi. I have a problem with using Joystick in Unity.
Input.GetAxis() works perfectly with Keyboard input, but when i plug in a joystick, and Unity picks it up, it returns incorrect values:
- When centered the Horizontal value returns -1 when it is supposed to return 0.
- When I move the axis to the right it goes from -1 to 1.
- when I move the axis to the left it JUMPS to 1. (supposed to go from 0 to -1)
I use this code to test it:
var Horizon : float;
var Vertica : float;
function OnGUI () {
GUI.HorizontalSlider(Rect(50,20,200,25),Horizon,-1,1);
GUI.VerticalSlider(Rect(20,50,25,200),Vertica,1,-1);
}
function Update () {
Horizon = Input.GetAxis("Horizontal");
Vertica = Input.GetAxis("Vertical");
}
Both my joysticks work correctly in other games, but fails to do so in unity.
You have the sensitivity set too high. It defaults to 1000 - open up the input settings and change it to 1.0 for each of your joystick axes.
Hi, I have not worked with joystick inputs since this question.
I have found something interesting though.
When I used a xbox remote. It all works fine.
I assume different controllers work differently with unity’s input system.
I’m having the same issue with my Thrustmaster Top Gun Afterburner stick and throttle.
I wrote a VB.NET program to test getting the imputs directly and all the numbers are correct.
I translated that program to C# and put it in a unity script and it returns 0 (zero) for all impute.
Note: It requires winmm.dll to work and I put a copy of that in the plugins folder.
I think Unity’s connections to the windows joystick drivers has a bug in it based on the fact that all other games and programs do not experience this issue with the inputs being screwed up.
Paul