#### Archived

This topic is now archived and is closed to further replies.

# Moving a character across hilly terrain

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

## Recommended Posts

I was wondering if anyone had any ideas on how this is professionally handled, such as in the 3D Mario and Zelda games. I can think of a way of doing it... using the x and z coordinates of the character, traverse every triangle in the terrain poly mesh until you find the triangle housing the point. Then calculate the y-value for the character''s position based on this triangle. But this solution seems to be very inefficient, especially when the terrain is made up of many, many triangles. Anyone have any suggestions? By the way, I''m just speculating now... I''m planning on using DirectX''s X Files for meshes. Thanks for your replies! Riskbreaker

##### Share on other sites
This is close to identiacal to a question I asked here a while ago (if the search function was working, you could just look there but..) Anyway, an easy way to solve this, even if it takes some more memory, is to make a struct called t_Triangle (or something) storing the coordinates of the three corners and the ID's (the array indexes) of the neighbouring triangles in it. That way you only have to traverse four triangles every time you need to calculate the height value (the one you was standing in last time you executed the function and the three neighbouring triangles)

This is an easy way, if you want a more complex and probably more efficient, look up on octrees or bsp-trees.

-Luctus

[edited by - Luctus on September 16, 2002 4:26:19 AM]

1. 1
2. 2
3. 3
Rutin
15
4. 4
khawk
13
5. 5
frob
12

• 9
• 9
• 11
• 11
• 23
• ### Forum Statistics

• Total Topics
633663
• Total Posts
3013236
×