Skip to main content
GameDev.net gamedev.net
🔒 Locked

Terrain Hugging ...

Started by djwarder Feb 4, 2004 at 6:01 AM 7 replies 850+ views
Original Post
djwarder
djwarder
Morning all!! Anyone have any ideas on how to go about making a NPC character walk over a surface, hugging the terrain properly? I thought about using physics & IK, but there must be an easier way. Any thoughts? Dan
superpig
superpig
If you''re using a heightmapping technique, you should be able to calculate the height at their position from that, just as with regular terrain vertices.
Richard "Superpig" Fine - saving pigs from untimely fates - Microsoft DirectX MVP 2006/2007/2008/2009
"Shaders are not meant to do everything. Of course you can try to use it for everything, but it's like playing football using cabbage." - MickeyMouse
gamelife
gamelife
If the NPC units are human characters, I guess IK is the only approach to position the foots correctly on the ground. For units of simpler shapes (e.g. tanks, bounded by a OBB) simpler methods exist.
djwarder
djwarder
Nope, not using heightmaps, just imported polygon terrain. Any good URLs on the subject at all?
djwarder
djwarder
gamelife ... What simpler methods do you mean? I could use this to start with, then IK for more precise techniques(as I''m use human characters).

gamelife
gamelife
I mean collison detection & response
You could find more information on the maths & physics forum.
de_matt
de_matt
Are you using an octree or quadtreee

Find out which segmetn the player is in then use vertical planes to find out which poly(s) the player is over then find the smallest dot-coord and go from there

It''s probably a little more complicated than that but there''s a basic idea.
Fald
Fald
If you want a really easy, but not very effective, way of doing this...

Assuming you use a DX mesh, you can use D3DXIntersect and use your players location as source, and send a ray straight down (0.0, -1.0, 0.0 most of the time)...

Then set new player.y to player.y = player.y - distance + desired height.

That should make your char hug the terrain.
djwarder
djwarder
Cheers all!! I''ll give it a go ...

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.