[ODE] Simple character control

Jon Watte hplus-ode at mindcontrol.org
Tue Mar 30 09:41:24 MST 2004


The request was for _simple_ character control; this is how we do it (in another physics API) and it works well. If you, the person, get hit by a 1 kg rolling barrel, you probably don't move backwards, although you'll be impeded in your movement by a bit. If you get hit by a 100 kg rolling barrel, I guarantee you you'll be knocked over.

If you want more "knocked-over" and less "sliding ball" then using another shape, such as a capsule (ccylinder) or tall box will probably work better. You can still move it around using a force applied at the center of gravity, but now you also need an amotor to try and keep the box upright, or a low center of gravity. This is less simple, but maybe more realistic, depending on what you want. (Me, I want fun-and-controllable, not realistic)

The single ball is not so very different from how your archetypical FPS like Quake does player movement; it sweeps/integrates a sphere along its BSP collision walls. If you feel that the control is not exact enough, just make the force constant (k in "f = (desiredVel - vel) * k") higher, so that the control system is stiffer. In fact, there's a convenience function in ODE to calculate "f" in that formula such that it's "perfectly stiff" i e you achieve exactly the velocity you want, in one step.

When you use an oblong shape, you may also wish to make it hover a little bit above the ground, to avoid problems with multiple ground collisions on uneven terrain. Send a ray downwards, and add a force that's proportional to desired hoverheight minus actual height, possibly with some damping. When rendering, you IK the feet to the ground. If you jump, you land and the box will fall below desired hover height, which will bend the knees. Again, we do this, and it works pretty well.

> And an addenum... what about animation?

You're note setposition-ing anything in ODE; you're extracting position to determine where to draw the mesh.

Note that animation is totally different from simulation in most games. You animate by using a high-resolution character skeleton, but you usually don't simulate that entire skeleton. Instead, you measure how far you've traveled across ground since last frame, and advance the walk cycle by that much; this avoids foot sliding on even ground; the IK takes care of the uneven ground case.

The extreme end of realism would be to simulate the skeleton as a rag doll, with forces applied to the joints to create the walk cycle. However, that doesn't qualify as "simple" at all :-)

Cheers,

			/ h+


-----Original Message-----
From: ode-bounces at q12.org [mailto:ode-bounces at q12.org]On Behalf Of Megan
Fox
Sent: Monday, March 29, 2004 6:16 PM
To: Ode
Subject: RE: [ODE] Simple character control


This results in a character that can be knocked around like a ragdoll,
though, doesn't it?  A human, when pushed, shouldn't slide away like an
ice-skate - they should remain where they are up until a specific force
point, where they would fall over.

Or do you suggest that the entity should react to the force, supply a
counter-force?

... but in that case, the entity would still be pushed back by slight forces
only to rebound back to position the next frame.  That doesn't seem
particularly ideal at all?


In a typical game, you don't want the player getting knocked back when a
barrel (slowly) rolls into them.  In fact, the players and entities should
typically be fairly assertive over rigid bodies, only reacting (assumedly
with a ragdoll or canned "fall back" animation) when the forces attempting
to be applied to the entities reach a certain critical mass... rigid bodies
should impede motion, but not knock the entities around like hockey pucks,
or in fact have much influence on the entity's movement at all (so long as
the forces applied remain below the critical point).


Forgive the confusion, but it seems like your solution treats players like
any other rigid body (that can be moved and knocked about just like any
other rigid body)?

-Megan Fox

> Add a force, not a velocity, each frame. Make the force equal to
> some constant times the difference of the velocity you want to
> run at, and the velocity you're currently running at, possibly
> clamped to some maximum force (if you don't allow infinite leg
> strength :-)
>
> You may also want to add a force that's a negative small constant
> times the velocity, to simulate air drag and/or ground friction.
> If you have sufficient air drag, you don't need to keep a target
> velocity, just apply the force when running, and air drag will
> make it stop at some top speed based on what the force and air drag is.
>
> Cheers,
>
> 			/ h+

_______________________________________________
ODE mailing list
ODE at q12.org
http://q12.org/mailman/listinfo/ode




More information about the ODE mailing list