Jump to content
  • Advertisement
Sign in to follow this  
be17_17y

Help Interact Character with Environment

This topic is 4908 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

sorry for asking this question.... i don't really understand how to interact our character to environment for example the ground : c(our game character) c------> ====== |||||||| c ========== if the character are in the ground with high y=3 then he move to lower ground y=1 then move again to different high of ground.... how can we handle this ? how if there so many varies of ground in high....are we have to save the high value of each ground...? please help me understand this... :) and the implementation in sample algorithm or code please... if you don't mind

Share this post


Link to post
Share on other sites
Advertisement
It all depends on how you are managing you terrain.

If you are using a height field, then your characters Y-Coord would depend on the current height the the vertex that it is standing on. To get a more accurate Y-Coord, what you would do is intropolate between the vertex heights on the triange that it is standing on. That way you would be at the correct height anywhere on the map.

To make sure that you arn't walking up mountins etc... You would check the slope of the triangle that you are walking on. Then if the slope is too steep, you would not allow the character to move onto it.

Share this post


Link to post
Share on other sites
If you can find the triangle your character's coordinates are over, this will give you the height of the position on that triangle:

FLOAT dist_to_plane = TriangleNormal.Dot( AnyTriangleVertex - CharPosition ) / -TriangleNormal.y;
return CharPosition.y - dist_to_plane;

Simple stuff, huh?

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!