Sign in to follow this  

3D platformer collision

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 this post

Link to post
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.
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 this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this