My current code makes a ball keep jumping whenever it hits the ground. But when it hits a vertical ground it keeps calling the jump function again and again. That is because OnCollisionEnter2D makes the isGrounded bool true as long as it is in touch with a vertical collider. I tried several ways for example this didn't work for me:
void FixedUpdate() { if(isGrounded == true){ Verticaljump(); isGrounded = false; } } void OnCollisionEnter2D(Collision2D collision) { if(collision.gameObject.CompareTag("H-Ground")){ isGrounded = true; } } As shown in the picture the OncollisionEnter2D starts and keep adding force on y-axis.Is there any way I can call a function only once even if the gameObject keeps colliding with a surface.
OnCollisionExit2D also does not work. So how can I call a function only once as it collides with ground and even if it keeps colliding with the ground?
