This is my player’s jump code:
if (isJumping == false && moveVertical >= .7f)
moveVertical = Speed * 70;
isJumping = true;
ball_move = new Vector2(moveHorizontal, moveVertical);
void OnCollisionEnter2D(Collision2D col)
if (col.gameObject.tag == "Ground")
isJumping = false;
When ball touches under of the collider it can jump again. How can i block this situation ?
The Collision2D parameter contains information about the collision. It has a contacts array that describes the collision points, each of these collision points contain a normal which is the outwards direction of the face/edge you collided with. You can use that to determine what side of the block you collided with (i.e. if the normal is pointing downwards (x 0, y -1f)) and then make it so you can’t jump if you touched it from below.