- Home /
Apply Input.GetAxis Smoothing to Joystick Axis
I'm using transform.translate to move a gameobject based on an input.getaxis command. I've set up two horizontal axes, one for keyboard inputs and one for joystick input. When you use the keyboard keys (a and d) for movement, you get a smoothing effect that makes the object glide a little after you let go of the key. On the joystick (xbox analog stick) this does not happen and the object stops as soon as you let go.
Can anyone tell me specifically why these two axes behave differently, and how I can get the smoothing effect to happen on the joystick axis? Code and input axes below for reference. Thanks.
void Update()
{
float translation = Input.GetAxis("Horizontal") * speed;
translation *= Time.deltaTime;
transform.Translate(translation, 0, 0, Space.World);
}
horizontal2.png
(16.1 kB)
horizontal1.png
(16.8 kB)
Comment