- Home /
Best way to prevent unnecessary input handling?
So you have a controller with analog sticks and you want to rotate your character to face certain direction. You apply the input from the controller to rotate the character to face the new direction but when you release your analog stick to return back to its resting position which is 0,0 the analog doesn't go straight back to pointing 0,0 but gets sidetracked a bit and applies this new direction.
So any smart way to prevent this? Raise deadzone or lower the input updates?
Answer by Loius · May 15, 2013 at 12:28 AM
While the input magnitude is not decreasing, apply rotation changes. While input magnitude is decreasing, do not apply rotation.
Perhaps? I've never tried. :)
Just keep track of your input magnitude from last frame and compare it to the one this frame.
That might be a good idea. Will try it. But what would happen if you decide to rotate the analog when you have it in 0,1 and rotate it so it goes -1,0 without going through the origin. That might mix things up a bit.
I would hope that if you spin from 1,0 to 0,1, that the control device would report the same magnitude. if it doesn't you might have to build a sort of dead zone into your own calculations. like, keep track of the maximum magnitude, and continue applying rotation until you've lost 0.1 magnitude ins$$anonymous$$d of just 'while not decreasing'.