I'm trying to make my player jump only when they are touching the ground and to do so I made an OnCollisionEnter(Collision collision) function, then I made another function called jump which makes the player jump when the space button is pressed the on the CollisionEnter function I call this function however this does not call the jump function, what am I doing wrong? when the player collides with the ground though it does print It's jumping as I have made a Debug.log check.
CodePudding user response:
OnCollisionEnter function is called only once, when your player collide the ground. If you want to do that you have to use a "isGrounded" boolean variable which you set to true when is grounded (in OnCollisionEnter) and set to false when you press jump. The jump control must be in the Update function.
CodePudding user response:
Thank you Cristiano Schiaffella enter image description here