I'm having a delay on Inputs

when i stop pressing a key the player keep going for some more frames
here is my code

public class Mover : MonoBehaviour
{
    private const string HORIZONTAL_AXIS = "Horizontal";
    private const string VERTICAL_AXIS = "Vertical";
    [SerializeField] float speed = 1f;
    

    private void Update() {
        float inputX = Input.GetAxis(HORIZONTAL_AXIS);
        float inputY = Input.GetAxis(VERTICAL_AXIS);

        Vector3 inputMoviment = new Vector3(inputX, 0, inputY);
        inputMoviment = inputMoviment.normalized;
        
        float movimentSpeed = Time.deltaTime * speed;
        transform.Translate(inputMoviment.x * movimentSpeed, 0, inputMoviment.z * movimentSpeed);


        Debug.Log(inputMoviment + " " + inputX+ " " + inputY);    


    }
}

I don’t think there is a problem on it
When stop pressing a key, the value don’t go immediately to 0, it passes thought every thing in batween as if it was analogic

image

Try using Input.GetAxisRaw() instead. GetAxis is smoothed, so gradually decreases. GetAxisRaw is -1, 0, or 1

1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms