Sprite BoxCollider2D passing through ground EdgeCollider2D

I have on my character sprite a BoxCollider2D set at its base covering the legs and where it touches the ground.

On the ground I have EdgeCollider2D covering all areas where the character can walk, run and jump.

I am finding that sometime I can jump up with AddForce() or “fall” from a ledge and when the character comes into contact with the ground it seems to pass through the base of the BoxCollider2D and finally gets caught (so it seems) by the inner upper line of the BoxCollider2D?

Yet if I stop the game and run again it lands correctly. I can run about and repeat the fall for example and say 4 out of 5 it lands correct but on the 5th…it passes through?

This is really becoming a pain as from what I can see my ground EdgeCollider2D should stop the character when the characters leg/feet BoxCollder2D comes into contact every time??

Help?

Thanks

You can use Rigidbody2D.collisionDetectionMode to select between Discrete (only collisions are the body position are detected) or Continuous (collisions from the last body position to the current body position are detected).

Discrete is faster but won’t stop colliders passing into/through each other (tunneling) if they are moving quick and/or the contacting colliders never overlap. Continuous is more expensive but it guarantees that tunneling won’t happen.

Try using Continuous as a test.

Thanks, will try that