WASD Movement legacy -> Input System (new) - no more interpolation / "sensitivity"?

Hi,

tl;dr - I would like to add artificial “sensitivity” to WASD key movement changes in new Input System, like it was available in legacy input system

I’ve switched my project from old legacy WASD movement of a third person character to the new Input System.

New Input system looks and handles great, but there is one major issue I personally have, which makes the gameplay significantly differ from the old legacy setup.

The legacy Input (GetAxis() in Update()) would feed the two (axis) float values gradually when changing directions.
Specifically, if you pressed ‘S’ to move the Character downwards, then additionally pressed ‘S’

  • ‘A’ to move Southwest, the value(s) would not instantly jump, but gradually - making the Character movement change more fluid.
    To my understanding, the “Sensitivity” setting was controlling this behavior in legacy setup:
    5485218--561900--upload_2020-2-16_11-52-15.png

I can’t find a possible way to set this up in the new Input System. I’m very likely just missing it. But after a day of toying around with the processors and watching most of the available YT videos on this and official documentation, neither of them addressing it - I’m calling for help here. lol.

Has anyone run into the same issue yet and knows how to get the more fluid feeling from the legacy system?

Just code acceleration yourself, old input acceleration is really limited and messy anyway.
Your character controller shouldn’t be relying on input features…

1 Like

So I revisited this issue in my project after some time and not getting it to work earlier, as I’m fairly new to programming.

For anyone stumbling into the same issue (as this is still not alleviated in the new input system) and finding this thread in search results, here is the code solution:

Mathf.SmoothDamp

You still get the movement the usual new way:

_controls.Player.Movement.performed += ctx => movementInput = ctx.ReadValue<Vector2>().normalized;

Then instead of feeding the movementInput.x and movementInput.y directly into your RigidBody move logic,
you SmoothDamp it before, and then feed the newly calculated values.
Unity Documentation for explanation on each value: Unity - Scripting API: Mathf.SmoothDamp

Beside of Vector2, declare following variables as well:

Vector2 movementInput;
float smoothTime = 0.3f;
float hVelocity = 0f;
float vVecolity = 0f;
float hCurrent = 0f;
float vCurrent = 0f;

Then in FixedUpdate(), or whatever suits you best, calculate the SmoothDamp and store it for each direction into a “new” variable. Right after that, set “current” float values equal to the just calculated “new” floats, so the next Update iteration can work with it.

float newH = Mathf.SmoothDamp(hCurrent, movementInput.x, ref hVelocity, smoothTime);
float newV = Mathf.SmoothDamp(vCurrent, movementInput.y, ref vVecolity, smoothTime);
hCurrent = newH;
vCurrent = newV;

Then you feed the “new” float variables into your Move logic, or whatever WASD / Controller input logic you want to achieve.

I hope this is helpful to anyone as well.

2 Likes

This one is indeed missing. It’s high up on the list of improvements to the action system.

To explain a little: currently, processors are required to be stateless. This stems from them being used for both devices/controls and actions. And for input controls, due to how they store state, a processor cannot additionally store its own state or trigger inputs when there are none in the event stream.

However, for actions, this requirement isn’t necessary and we intend to explicitly allow and support processors on action bindings to keep local state as well as to add a way for input to be generated by input processors without requiring actual input.

2 Likes

MassimoFrancesco It’s actually a great solution. You can also make it into a single line if you use Vector2.SmoothDamp. This code is based on your solution.

You need to make these field variables:

    private float animationSmoothTime = 0.3f;

    private Vector2 animationVector;

    private Vector2 animationVelocity;

And then you do the following in Update

  animationVector = Vector2.SmoothDamp(animationVector, movementInput, ref animationVelocity, animationSmoothTime);

Then you can use the animationVector to make smooth transitions in your Animator.

  animator.SetFloat("Vertical", animationVector.y);
  animator.SetFloat("Horizontal", animationVector.x);
1 Like

I’m glad this is already on your list. Will be a good improvement.
I really like the new input system, for what it has to offer so far. It’s a huge step forward from the old one. Great job, thank you!