When a selected key is pressed in Unity, the Input Manager's Input.GetAxis("Horizontal")
function returns a gradually increasing number up to 1
(or negatively -1
) for the length it is held down. The rate at which it increases is based on the value Sensitivity
in the Input Manager. Similarly, the sticks on a controller return a value depending on how far they are tilted.
Is there a proper way to make the value immediately snap to -1 or 1 through the manager, or would I have to write a couple of if
statements in my script to handle that?\
Edit: A very short and readable scripting option would be if (Mathf.Abs(isRunning) > 0) isRunning = Mathf.Sign(isRunning);
if(value < 0) {...} else if (value > 0){...}
? \$\endgroup\$