Help Interact Character with Environment

Started by
1 comment, last by Jiia 18 years, 11 months ago
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
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.
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?

This topic is closed to new replies.

Advertisement