Double jump logic

When the player jumps, the _input.jump is true

the Grounded bool becomes false

the player is in the air. upon landing reset
when another input,jump happens while not grounded we should increase height and play the animation.

private void DoubleJump()
{
    
    if(!Grounded)
    {
        if (_input.jump && _input.jumpCounter >= 2)
        {
            print("Double Jump");
        }
    }
    
   
}

the initial jump makes the player not grounded true and the input.jump is true making the DoubleJump Function play without the second jump input. I thought i could use a counter but i run into the same problem. I feel like im close but im missing the logic of it so i need help.

Here’s my full treatment of multi-jump, coyote time and jump buffering:

Full source here:

proximity_buttons is presently hosted at these locations:

https://bitbucket.org/kurtdekker/proximity_buttons

2 Likes

We’d probably need to see full code to help more directly.

Though I would imagine, if the player is grounded when they jump, you don’t ever call DoubleJump().

Ergo:

bool jumpInput = _input.jump;
if (jumpInput == true)
{
	if (Grounded == true)
	{
		Jump();
	}
	else
	{
		DoubleJump();
	}
}

i see you stored the bool in a variable where im just using the input.jump which comes from player input. when im home ill try this.

The variable isn’t going to turn out to be the issue/solution. Something odd about spiney using == true syntax though :slight_smile:

I think I would create a Jump method that could determine whether it was a single or double jump all inside of that method.

I solved it!
because the initial jump logic was nested inside of the Grounded check. I separated them
In the jump function,
1st if - I checked for a grounded state and set those conditions,
2nd if - i checked for input seeing if the player was grounded or not, running logic based on player state, finally the else condition to reset things when the player was grounded and gravity.

Nothing odd about it. Some of us do it as we find it more readable.