[ODE] Avatar control vs gravity

Gary Haussmann ghaussmann123 at msn.com
Wed Nov 17 13:09:01 MST 2004


I once tried to solve the same problem; getting an avatar to walk around on 
hills and valleys consistantly with gravity.  My final solution was a bit of 
a hack, but it seemed to work OK.

Basically I manipulate the contact point between the avatar and the ground.  
By setting the fdir1 component to point forward and then tweaking the 
'motion1' value, you make it appear as if there was a conveyor belt along 
the bottom of your avatar's geom that pushes along the ground (or whatever 
you're standing on).  I also had to add a restorative force to keep the body 
upright, but besides that everything else worked pretty well.

Running up or down hills works as you expect, with the mu of your contact 
determining how steep of an incline you can go up before sliding or falling 
over.  Also, when you run over or on top of other bodies they react 
appropriately; that is, you move forward and they get pushed backward from 
your POV.  The hardest part of this process is tweaking that contact joint 
between your avatar and the ground to get the behavior you want.

Gary


>The main issue is applying the forces properly.  Instead of applying a huge 
>force constantly, you instead want to apply a force to get the necessary 
>acceleration.  For instance, on a frictionless plain, you want the forward 
>command to speed up the avatar to a certain speed, and then provide no 
>further force (and thus no more acceleration).  This will then work out 
>fine for hills, where the avatar will walk up slower, or not at.  You can 
>even decouple it even more, and have the max velocity, acceleration rate, 
>and max force, so that the object has a slow acceleration but huge max 
>force - it can climb up any slope and push through any obstacle, but 
>doesn't instantly zoom off the map when you move.




More information about the ODE mailing list