- Home /
Question by
bthanse · Dec 02, 2019 at 06:11 AM ·
controllerflight
Joystick whole range
Anybody know how to change the joystick so it is 0% at bottom, and 100 % at top ? Like now it is +100 % at top, 0 % middle, and -100% at bottom.
Comment
Answer by developeration1 · Dec 02, 2019 at 06:48 AM
I don't know if there is a Unity function or method for that, but with a you can calculate that by getting the axis plus one and divide the result by 2, something like (Input.GetAxis("Horizontal") + 1) / 2
, you can save this in a variable and work with that. You can test it out if you do some math tests:
(-1 + 1) / 2 = 0
(0 + 1) / 2 = .5
(1 + 1) / 2 = 1
(.5 + 1) / 2 = .75
(-.5 + 1) / 2 = .25
Now if you want to get percentage, just multiply the number by 100 Hope that helps!
Your answer
