- Home /
Joystick input Problem
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.
Answer by swiftcoder · Dec 27, 2012 at 10:22 PM
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.
Answer by Dazdingon · Mar 12, 2013 at 12:05 PM
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.
Answer by Paul_Smith · Mar 08, 2015 at 05:41 PM
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
Hey there!
Did you solve the bug with your controller? I'm having a similar issue as Dazdingo, but I cannot replace my controller, because I have to work with it for my bachelor thesis...
Your answer
Follow this Question
Related Questions
Steering Wheel / joystick GetAxis trouble 0 Answers
joystick movement 2 Answers
Input.GetAxis returning nonsensical values for HID Sensor/GameController 0 Answers
Map mobile joystick to Input.GetAxis("Horizontal") and "Vertical" 1 Answer
Get DPad input value via GetButton instead of GetAxis? 8 Answers