This is in my head for the last couple of days now:
Imagine a world (2D, sideview), where everything is made out of polygons. One of that polygons is the player character (human). Now I want to move the player. I’m thinking in 2D here, but the problem must be quite common in 3D worlds. How do modern games do the movement of the player in such an environment? Does anyone know?
Googling unfortunately didn’t help…
My current approach is:
- move the player according to key input
- do collision detection
- if a collision occured, shift the player up, until no collision is detected anymore
- if the player was shifted about max-length and there still is a collision, there seems to be a real collision with a wall or something, reset player position
There are problems comming with that, one of them is:
The player polygon is a box. Standing on a line going up 45 degrees or something like that, it looks like one of the players feet is floating in the air. I could just move the player a bit down so that both feet are on the ground, but then I’d have to handle the collisions coming with that.
Am I doing something terrible wrong? Is there a “standard” approach for moving in polygonal environments? Any hints and thoughts are highly appreciated