- Home /
Input.GetAxis returning only -1, 0 or 1, nothing between
I'm trying to use a PS3 controller (though the MotioninJoy Tool, so it appears like an Xbox 360 controller) and everything is working fine, except the joysticks are only offering three values: -1, 0, 1. My problem: I want a half-push to trigger 0.5, a quarter to trigger 0.25, etc. I believe the docs say they're supposed to work this way, so I'm not sure what I've done wrong.
Here's the code (the only bit which listens for the joystick input) and prints it:
function Update () {
Debug.LogWarning("J1V: "+Input.GetAxis("J1V"));
Debug.LogWarning("J1H: "+Input.GetAxis("J1H"));
Debug.LogWarning("J2V: "+Input.GetAxis("J2V"));
Debug.LogWarning("J2H: "+Input.GetAxis("J2H"));
}
I mapped J1V to the left joystick's vertical axis and the others according to the stick and axis, accordingly. (Hence than name "1V", mapped via Edit->Project Settings->Input, mapped "J1V" as Type:Joystick Axis, Axis: Y axis, Joy Num: Get Motion from all Joysticks.)
I know that it works since these warnings do print, but they print only print -1, 0 and 1. Actually, instead of 0 they print 0.0142733. Not sure if it matters, but worth noting.
Any ideas of what could be causing my scale to intermediate values? Thanks!
So does the motionInJoy force the values to like .25 and .5 like you were saying?
Are you getting .01427 for when it should be 0? That's pretty darn close sounds like your joystick might be a little off or maybe that kind of precision difference is normal?
Unfortunately I never used joysticks yet so I can't help you but it sounds like your scripts are not set up to differentiate the various input phases? It's only detecting the full direction not any of the middle ground?
Impossible to help without seeing more code I think. $$anonymous$$aybe someone else knows though.
No, the $$anonymous$$otioninJoy is just a PS3-to-360 controller emulator. It seems to be working flawlessly; when I open Window's device manager it sees an Xbox 360 Game Controller and the Test tab shows all degrees of inputs properly.
Yes, the 0.014 bit shows on zero. It may be the remote, and I can create a "dead buffer" if needed. It appears under the Edit->Project Settings->Inputs that there are built-in dead ranges for each axis. It defaults to 0.001 and when I tested it to 0.1 the "zero position" of the controller now reads 0. When I tested at 0.01 it reads 0.005312143. I don't think that matters too much.
Honestly: that's all the code there is. I have an airplane with this controller attached and it prints these results. Since the appropriate axis are changing on the correct inputs I know I have them mapped right, but they're acting like binary inputs rather than scaled ones, which is my trouble.
Answer by myingling · Nov 10, 2013 at 04:47 AM
Got the answer from somewhere else:
Turned out the input settings scale needed to be changed. I thought the defaults of the Gravity was 1000, Dead was 0.001 and Sensitivity was 1000. Someone has me change them to Gravity = 0, Dead = 0.19 and Sensitivity = 1 and things started working. I'm now playing with each, but this was my problem.
Your answer
Follow this Question
Related Questions
Creating an input manager that supports axis 0 Answers
How to get an axis without defining it in the InputManager 0 Answers
Problems with joystick / controller axes being 1/-1 "way too often" 1 Answer
New Input axis with Numpad Keys 2 Answers
Help In Making a SphereCast for 3D Tire! Working RayCast Script included! 0 Answers