# Help Interact Character with Environment

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

## 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 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 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?

• 15
• 11
• 9
• 38
• 16
• ### Forum Statistics

• Total Topics
634128
• Total Posts
3015693
×