3D platformer collision

Started by
2 comments, last by Firefly08 14 years, 3 months ago
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
Advertisement
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.

Please don't PM me with questions. Post them in the forums for everyone's benefit, and I can embarrass myself publicly.

You don't forget how to play when you grow old; you grow old when you forget how to play.

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.
Hi,

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

This topic is closed to new replies.

Advertisement