I’m trying to stop my player from double jumping. I’ve written my code to check if whether or not the player has collided with the ground. My code works if I’m using a keyboard button with my ground collision check, but when I switch my code to use a sprite button with the same ground collision check, it doesn’t work the player will be allowed to jump when I click my button the player can jump an infinite number of times.Literally jumping over the level. When I build my game to my phone its the same thing of course.
See my code below. I appreciate any and all assistance. Thanks!
if (Input.GetButtonDown(“Jump”) && isGrounded == true)
isGrounded = false;
public void Jump()
rb.AddForce(0, jumpForce * Time.deltaTime, 0, ForceMode.VelocityChange);
void OnCollisionEnter(Collision collision)
if (collision.gameObject.tag == “Ground”)
isGrounded = true;