GetAxisDown?

I’m trying to make a jump function, but I can just keep holding the button so when I land it jumps immediately upon impact. So that leads me to the question of how do I make GetAxis, act as GetAxisDown? I looked up other answers but I couldn’t figure anything out from them. Any help would be appreciated. Thanks in advance :slight_smile:

Try it

private bool inputEnabled = true; // Variable to lock control

private void FixedUpdate()
{
    var input = Input.GetAxis("Horizontal"); // get input

    if (input != 0) // input axis pressed
    {
        if (!inputEnabled) // verify lock control
            return; // cancel if locked
        inputEnabled = false; // lock input

        // Your code here
    }
    else // input axis released
        inputEnabled = true;
}

GetAxisRaw("MyAxis") returns 1 if any positive value or -1 if any negative value. You can just do:

if (GetAxisRaw("MyAxis") != 0)
{
    // my code
}

Use GetButtonDown(). Works in the same way, except you can’t use axis configurations like joystick or mouse movement.