Jump to content

  • Log In with Google      Sign In   
  • Create Account

How to allow player to walk in a Mesh?


Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.


  • You cannot reply to this topic
5 replies to this topic

#1 bardackx   Members   -  Reputation: 204

Like
0Likes
Like

Posted 24 July 2014 - 05:50 PM

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?



#2 HappyCoder   Members   -  Reputation: 4499

Like
6Likes
Like

Posted 25 July 2014 - 12:18 AM

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

#3 frob   Moderators   -  Reputation: 38705

Like
3Likes
Like

Posted 25 July 2014 - 12:55 PM

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.


Check out my book, Game Development with Unity, aimed at beginners who want to build fun games fast.

Also check out my personal website at bryanwagstaff.com, where I occasionally write about assorted stuff.


#4 bardackx   Members   -  Reputation: 204

Like
0Likes
Like

Posted 25 July 2014 - 10:40 PM

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



#5 haegarr   Crossbones+   -  Reputation: 7023

Like
1Likes
Like

Posted 26 July 2014 - 03:49 AM

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.


Edited by haegarr, 26 July 2014 - 03:50 AM.


#6 bardackx   Members   -  Reputation: 204

Like
0Likes
Like

Posted 27 July 2014 - 11:41 AM

finally I know where I should be heading to, thanks






Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.




PARTNERS