# How can I prevent movement from analog joystick “bounce”?

I'm working on a top-down game where the player can move up/down/left/right. The sprite changes to the corresponding direction, and I have an internal value that tracks the direction the player is facing.

The actual movement is handled just by doing rigidbody2D.MovePosition(player.position + movement * speed * Time.deltaTime); and it's working fine. Direction is determined by looking at the absolute values of all 4 axis values and seeing which one is greatest.

The problem I'm having is when using an analog joystick on a controller. So, if you suddenly let go of the stick, it has a little "bounce" where it goes past the center, and into the opposite direction.

I uploaded a slow-motion video of the joystick being released, to show this "bounce."

See GIF here

I added some logging to the input, and here are some numbers:

The joystick bounce always ends up being somewhere between < 0.1 to up to 0.5, for maybe 1 frame in time.

What can I do to mitigate the effects of this bounce? It's causing my player to suddenly look in the opposite direction if they suddenly stop moving.

I've had these ideas for solutions, but I'd love some advice:

1. Increase deadzone to be over 0.5 - This seems like an easy fix, but that feels like it's too big of a deadzone.
2. Ignore input if the difference between last frame and current frame is greater than a specific value (maybe 0.5?)
3. Average out input over the last few frames and then move? Seems like it could be buggy though (and feel laggy)
• Have you tried any other controllers? This seems like a hardware problem. – Ed Marty Dec 20 '18 at 17:23
• The bounce shown on the GIF is pretty crazy. I just tried a few of the XBox controllers on my desk and none of them have a bounce this strong. I suggest trying a different controller. – mt_ Dec 20 '18 at 20:31