views:

187

answers:

3

I am trying to make a simple 3d platform game. The issue I'm having is with the collision detection and response. I am currently representing my player character (for wall and floor collisions) with a sphere.

I employ a simple gravity force and directional forces using the arrow keys for movement.

My problem occurs when I come to an edge (like a cliff). I slide over the edge like a ball would, but the behaviour I'm looking for is to fall off the edge like an upright cylinder. A boolean "I am on the platform, or I am not on the platform", and not "I'm sliding off the edge gradually".

The problem with using an upright cylinder is that sliding up stairs automatically becomes impossible, and when walking along any kind of slope, the cylinder must either touch only by one edge, or be partially embedded in the slope.

What is a good collision representation of the player character in a 3d platform game?

+1  A: 

Try an oblate ellipsoid. Just stretch the sphere along the vertical axis.

Javier
A: 

It sounds like your ideal solution would be an upright cylinder with rounded edges. It would still tip over straight edges, but the rounded edges would allow you to slide up stairs. You may have to play with the rounding radius in order to get the effect that you want.

e.James
+1  A: 

You may keep the sphere for the collision detection.

And if you find collision, then you should compute more accurately for collision, by dividing your character into several components.

One common solution is to used sphere (because the collision is easy to compute) for the head, the trunk, and a cylinder for the legs and the arms (you can also add sphere for the hands and feet).

Do you have the possibility to read this book ?

ThibThib

related questions