Sign in to follow this  

Help Interact Character with Environment

This topic is 4595 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
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

This topic is 4595 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.

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