Here is a video where i showcase the issue. The edges have box colliders attached to them. I tried changing the max penetration in the Physics2DSettings but it still acts weirdly… I also tried changing the “Collision Detection” property to continuous on the rigidbody component, but it still didn’t work. So is there any way to fix this? I assume it has something to do with how unity collisions work
First, reset the max-penetration back to its default; it’s actually very bad to change it unless you know what you’re doing.
Unity 2D physics (Box2D) provides rock solid detection for this kind of thing, especially continuous collision detection which you should definitately use for faster moving objects against thin colliders like edges.
The most likely reason it’s happening is because you’re causing an overlap with the edge by modifying the Transform component on your ‘player’ to either reposition it or change the angle. When you do this, you’re warping it from one position/angle, instantly to another causing the overlap which the physics system cannot easily solve, especially if you’re doing this continuously, stomping over what it’s doing.
You should use Rigidbody2D.MovePosition & Rigidbody2D.MoveRotation to change the position and angle of the Rigidbody2D respectively.