How to prevent clipping into wall with composite collider

Hello, I am making a top down minigolf game. I use tilemap collider+composite collider for the blocks and when I make too fast move, the ball just goes inside the wall. Is there any way to prevent this without limiting the power of the move?

Not enough information on how the “ball” is moving. Presumably it’s a Rigidbody2D set with a Dynamic body-type and its moving via its velocity and not a Kinematic one and you’re using queries to determine where to move to?

If it’s Dynamic then presumably you’re using Discrete collision detection which means it can step through colliders depending on how fast it’s moving. This is fast to compute. You can set it to Continuous collision detection which will completely stop this but it’s more expensive to calculate.

This’ll also be made worse if your using Outline mode in the composite because there’s no “inside” with such edges so you won’t get naturally pushed out of overlap; quite the opposite because if it’s an edge, it can get pushed to the other side of it if it’s over half way over it or skip right over it if it’s fast enough.

1 Like

Thanks! I didn’t know what information to include, everything you said was right. I switched it to continous detection, and it works!

1 Like