How to allow player to walk in a Mesh?

Started by
4 comments, last by Bardack_x 9 years, 9 months ago

I am writing my own engine in Java and OpenGL (for fun and learning and because I have the free time) I have the rendering and animation parts done (sufficiently done).

I want the characters and player to walk a terrain represented by a Mesh, how do I do that?

Advertisement

Define a capsule shape for the characters. Next check the collision of the capsule shape to each triangle in the terrain. If they overlap, push the capsule out of the triangle. You can accelerate the collision against the terrain by using a octree.

Collision detection can be quite tricky. I would recommend implementing collision in 2D first to get a feel for how its done. When you do try to tackle 3D, try it first using shapes that cannot rotate. This article might be useful.

If making your own collision detection system sounds hard, (because it is), I would recommend using an existing physics engine, like bullet.

My current game project Platform RPG

In addition to what HappyCoder wrote above, in many games there are multiple meshes involved. One is used for rendering. A second, simpler mesh is used for physics. A third greatly simplified mesh is used for navigation, pathfinding, and AI.

thanks for your responses; so the walking in a terrain feature should be delegated to the physics engine? —it's time to update that old particle only engine, xD— I wonder how pikmin handles it

so the walking in a terrain feature should be delegated to the physics engine?

There are several sub-systems involved.

a.) AI (for the NPCs) for path finding: What way to go to reach the target location? As frob has mentioned, this can be solved by using a dedicated mesh.

b.) Animation blend controlling: Set by AI or player input, which kind of motion is used (walking, running, ...).

c.) Animation playback: How is the character posed at time.

d.) Collision correction: reacting on obstacles and ground.

Details depend on the kind of game and character implementation, of course. Assuming a 3D world with skeleton based characters...

Things are relatively easy if you are willing to accept some artifacts like foot sliding and averaged slopes and steps in terrain. It is not easy to get rid of those issues. A locomotion sub-system for foot placement is one possible undertaking. Foot sliding alone can also be reduced to a minimum if the animation playback is not controlled by time but by the made way; e.g. the Wolfire engine follows such a approach. So, for completeness we need to add:

e.) Locomotion control: foot placement and pose controlling.

However, most games especially in the hobby area do not deal with such complex things like locomotion.

finally I know where I should be heading to, thanks

This topic is closed to new replies.

Advertisement