View Full Version : Terrain Hugging?

02 February 2004, 12:02 PM
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?


02 February 2004, 01:43 PM
Well the simplest way is just to cast a ray straight down and see where it hits the ground.

Then you'll wanrt to alter your walk speed and animation based on the slope.

You'll probably want to have your path-finding routine avoid harsh slopes as well.

02 February 2004, 02:16 PM
Ok. Using a 'NavMesh' scheme to reperesent terrain at the mo, so am already restricting surfaces with a greater angle of 60 degrees or so.

Did think about just using a simple raycast approach, but not sure how to tackle the problem of character feet slippage over the surface, without resorting to IK. Any ideas?

02 February 2004, 02:39 PM
The ray casting technique is the main one that I've heard of before...

Take a look at this article ( (On Gamasutra ( - free login required) - it talks about terrain AI... I haven't read it myself but I suspect it will cover what you are after...

edit: Having quickly flicked through the article, it's less about terrain hugging, more about using AI to get NPCs to use the terrain to their advantage (the example it gives is finding good sniping spots...) Still an interesting article, though... take a look at the terrain section of ( for more terrain stuff - most of it seems to be geared more towards terrain generation, though....

02 February 2004, 02:43 PM
Not sure how they're coping with this in the loft, but it seems the eaisest solution is to change the speed of the walk cycle depending on how steep the terrain is (for example).

Of course I'd say this is something you only want to worry abotu once you've actually got your little guys walking around on the terrain in the first place

02 February 2004, 04:02 PM
Interesting!! Didn't think about changing the walk speed, but had thought about altering the characters' gait.


02 February 2004, 04:31 PM
I think the onus is on the user in this case to supplu an animation clip suitable for rough/steep terrain. Unless you want to be generating all the animation yourself... keep it simple i reckons.

CGTalk Moderation
01 January 2006, 09:00 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.