# 3D platformer collision

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

## Recommended Posts

Hi, I am making a 3D platformer (like Jack and Daxter and Rachet and Clank) and I am currently trying to add in collision. What I was thinking was having two collision meshes, one for walls, one for floors. For collision with the floor I was simply just going to shoot a ray down below the player and adjust the players height based on that. And then for the walls add in some Bounding Box-Mesh collision. The problem is I have my one ray shooting down from the centre of my player so when he gets to close to an edge he falls off even though he should be still standing on the edge. My thought was maybe use more rays at each corner of the player or maybe at his maximum and minimum points? I'm really struggling with this, can someone help me out, or suggest a better way to do this? Thanks, Simon

##### Share on other sites
Welcome to the complex world of collision detection! The first question which you have to answer yourself: how do you want it to work?

It's not unreasonable that a player would not be supported if there's nothing under the center-point. Shooting rays for vertical position detection is quite common, by the way. You can, of course, shoot several rays from various positions. If both the player and floor are essentially AABBs that may give you what you want. If the player and/or floor are not always aligned with axes*, and you want the player to be supported in some other manner, you'll have to use a different method.

*i.e., irregular shapes or non-aligned rectangles.
Quote:
 a better way to do this?

How do you want it to work?

EDIT: in a couple of my applications, I use a sphere at the "bottom" of the player and allow the player to "recover" if he starts to "slip" off the edge. I use ODE for collision detection and physics. As that bottom sphere slips past the edge, one can see visually that the player is beginning to drop while the sphere is still in contact with an edge.

##### Share on other sites
I would use some kind of sphere/capsule-triangle intersect test using an octree or kdtree, also maybe having a seperate triangle mesh for collision with lower triangle counts for less calculations.

##### Share on other sites
Hi,

Thanks for the replies, I will definatley try using spheres.

1. 1
2. 2
3. 3
4. 4
Rutin
12
5. 5

• 12
• 18
• 10
• 14
• 10
• ### Forum Statistics

• Total Topics
632662
• Total Posts
3007702
• ### Who's Online (See full list)

There are no registered users currently online

×