Hello! Thank you for reading! If you don’t know coyote time/ledge assistance is when the player has a short amount of time to jump after leaving the platform they are on. This is how I am doing it:
First I define a float called groundedRemember.
public float groundedRemember = 0;
Then in Update() I subtract Time.deltaTime from it.
groundedRemember -= Time.deltaTime;
Also in Update() I check if the player is grounded, if so, I set groundedRemember to 0.25.
if (grounded)
{
groundedRemember = 0.25f;
}
Then if the player jumps and all the conditions are true (jumpPressRemember is for a jump buffer, and topChecker is to make sure there is nothing above the player) then make the player jump, making sure to reset the groundedRemember timer.
if ((jumpPressRemember > 0) && groundedRemember > 0 && !topChecker.GetComponent<TopChecker>().touching)
{
jumpPressRemember = 0;
groundedRemember = 0;
Debug.Log("Jamp");
playerRb.AddForce(Vector2.up * jumpSpeed, ForceMode2D.Impulse);
jumpSound.Play();
}
The problem is if the player spams jump they are double jump for a split second.
I thought resetting the timer would fix this but it does not.
Why is this occurring?
I can upload more details if necessary.
Thank you again! Any help is appreciated!