Skip to main content
2 of 3
added 104 characters in body
General Waters
  • 1.6k
  • 2
  • 21
  • 30

You can use a raycasting (or linecasting) based collision detection system. At a very high level, you cast rays from your player (preferably from the edges of it's collider box) into the game map. When the ray hits something, you can check to see what its hit, and if it's a collidable surface, resolve the collision and adjust player movement as appropriate. This method is pretty agnostic to how your game map is built (tilemap, models, geometric shapes, etc).

For more technical details, you can view my own question on a similar topic. While the code presented is C# (and for Unity), you could easily adapt it for any language.

Here's an image to help visualize the system

Source: Yoann Pignole

Some resources:

General Waters
  • 1.6k
  • 2
  • 21
  • 30