New input system axis just gives 0 or 1, instead of intermediate values as in old getAxis()

I’m trying to learn the new InputSystem. I have made a control for speeding / braking with the up / down arrow keys. I made a “driving” map with key bindings for the up and down arrow keys.

This works! But the problem is, these key presses now only return -1, 0 or 1.
With the old input system and getAxis() you would get a smooth transition that slowly goes back from 1 to 0 instead of being either 0 or 1.

Even setting the action to “value” and “axis” has no effect, see screenshot.

How can I get smooth transitions in the new inputSystem?

1 Like

The new input system doesn’t have support for this yet. It’s apparently on the roadmap for future versions of the module.

Basing my info on this post: How to reproduce the standard Input.GetAxis("Horizontal") in the new input system?

I know you can write your own custom Input processor Processors | Input System | 1.0.2 but I’ve never done that and I’m not sure what one would look like that does what you want.

You’ll have to do it yourself in your script, or go back to the old input system.

2 Likes

Try using Mathf.Lerp() to smooth things.

1 Like

Thanks for the hint, I found this lerp solution using MoveTowards:

float inputValue = controls.Driving.Speed.ReadValue<float>();
currentValue = Mathf.MoveTowards(inputValue, currentValue, 0.25f * Time.deltaTime);
transform.Translate(Vector3.forward * Time.deltaTime * currentValue * speed);

My only question is, do I need Time*deltaTime twice here?

Excelent… Thanks

Vector2 currentMovement = movement;
movement = movementControl.action.ReadValue<Vector2>();

movement.x = Mathf.MoveTowards(currentMovement.x, movement.x, 5f * Time.deltaTime);
movement.y = Mathf.MoveTowards(currentMovement.y, movement.y, 5f * Time.deltaTime);
.
.
.

what is movementControl here

movementControl is an input action that you define in the inspector.