LoginLogin

Perfect collision

Root / Programming Questions / [.]

ChaseCZCreated:
How do i make a perfect map collision/wall so the player/sprite can't walk through it?

Draw a line between an entity's starting and finishing point, and determine if that line crosses any other suspected lines of collision. If so, you could for example: revert back to the starting point; revert to a point where the entity had not collided; reposition the finishing point to the surface of the thing it collided with.

Check for collision on several smaller steps each frame. If you've watched any Pannenkoek2012 videos, you should be familiar with how Mario moves in SM64. That's a decent example.