# FPS player collision

This topic is 4175 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I'm starting to add collision detection to my player of my FPS which already has a AABB, I need to know how to detect if the AABB of the player collided against my geometry with all the things that a FPS player needs to do (like go smoothly up stairs and not collide with small stones and such). Right now I want the collisions to be done on AABB (no OBBs), and I have seen tutorials and documents where they show the algorithms for things such as ellipsoids, spheres and such but I want to use AABB. Could anyone give me some pointers to information about doing that or maybe some algorithm? Thanks.

##### Share on other sites
One super simple approach is to treat the world as a heightfield. Every time the character moves, calculate (by ray-trace or simple heightfield lookup or whatever) the height of the world below the character's feed (or some reasonable step-up distance above his feet). Then, when you move the character, reset his height to be the world height at the new position. Essentially what you are doing is having the character follow the height of the world. You're letting him walk up onto things that are slightly higher, or fall down into holes or off of things. Stairs are handled transparently. If your engine supports ray tracing against dynamic objects, you could even have the character go into an elevator, then animate the elevator and have the character move with it, without any special code. Its conceptually very simple. You can do this without even having an AABB. You can do this in an AABB context by just using the character's AABB as a basis for determing where the support is. And, you do want to do some level of check along the direction of walking so the camera doesn't poke through walls, etc. The AABB would add this. And, depending on your game world, you could just do your AABB test in the horizontal plane, and just the ray-trace through the center of the AABB for heightfield variations.

As for basic AABB collision ideas, I didn't have an immediate link for you, but I found the following with a quick search:

Basic Collision Detection and Response

And,

Collision Detection

I haven't read either to determine whether they are really useful, though at first glance they appear to be. Both discuss more than just AABB's, but at a reasonable level to start with.

One of your challenges will be how to detect AABB collision against your world geometry....if you only want to to AABB vs. AABB, then you will have to create a collection of collision boxes that approximate your world geometry. Might be doable. Stairs would be represented by one box per step. Stones could be represented approximately by 1 box each. The main terrain, if it is flat...one box. You get the idea.

Hope this helps a bit!

1. 1
Rutin
42
2. 2
3. 3
4. 4
5. 5

• 18
• 20
• 14
• 14
• 9
• ### Forum Statistics

• Total Topics
633376
• Total Posts
3011558
• ### Who's Online (See full list)

There are no registered users currently online

×