From 2D Collison to real 3D

Started by
1 comment, last by Fingers_ 16 years ago
hi folks!, i have made a Doom like game from scratch. Anyone who has played doom knows that you can´t jump and in my game you can only stay on one floor-level. I want to increase the collision detection so you can jump around on different platforms with different height. for now i am using polygon as room-definitions with vertex point that sum up the walls. This is good because for changing the structure of a room i only have to move vertex in my collection of a specific polygon. Now, i want to make my game a Quake game instead, this so i can jump over stuff and climb stairs and jump to other floor-levels. The Question is if i can still use this "2D" collision detection and set height to my vertex in my poly or if i have to build up my level complete with planes? With the polygon i am stuck with one height everywhere. and i also have to define if the player stands on floor or not? point inside polygon? othervise use gravity to pull player down. How is you collision detection build in a game like this? Polygons with static heights or planes put together to build a complete level? planes that represent floor, wall, and roof?
Advertisement
Quake (I, II and III) is open source these days, so you could look to see how they did it. Quake uses a 'positive map' (i.e. all the walls and floors are cuboids or other convex polys); you do 'proper' 3D collision detection by performing AABB-poly tests (the player is an AABB I believe). You could use a sphere or ellipsoid for the player instead.

The Unreal series uses 'negative maps', whereby the rooms you can walk in are defined as regions which are cut out of solid space. In this model you can find if a player is colliding by checking whether he is completely inside the map, but be aware that sometimes the player will be in a connecting space between two rooms and is not completely inside any one cutout. Again, you use player-plane collision checks.
In Doom, the height is handled in a pretty simple fashion. Each sector (ie. your room polygons) has a height value for the floor and ceiling. When you move, the game checks which sector(s) the player character is in and restricts your vertical motion based on the sector heights. You sometimes need to take more than one sector into account, e.g. when you're standing on the line separating two sectors.

The lack of upward jumping in Doom was not actually a limitation of the engine but a game design decision... Id decided to just automatically move the player up if he hits an edge of a sector less than 24" above his foot level, which was enough for "running jumps" across small gaps and of course climbing stairs.

This topic is closed to new replies.

Advertisement