# [ODE] Using ODE to simulate a Mech game,

Jon Watte hplus-ode at mindcontrol.org
Thu Jun 24 15:47:45 MST 2004

```Awesome! I think any game with mechs is not a total failure :-)

There are two ways to go:

1) Treat the mech as a player character, and use local animation
only. That indie action mech fighter based on Torque (Dark
Horizons: Lore, perhaps?) does this, I think.

2) Treat the mech as an actual rigidly animated body, and make it
walk like a robot. I don't know if MechWarrior IV does this,
but I'm pretty sure MechAssault does. Or they do a GREAT job
of faking it :-)

You're currently trying to go route 1. If that's what you want,
you should probably use a capsule, rather than box, because it
collides "nicer" with the ground. You could give it 0 friction,
and instead just record whether it's in contact with something,
and apply a velocity dampening force if that's true.

Then you get the orientation of the capsule, and apply torque
to make the capsule spin towards the identity position. Ideally,
you also take the angular velocity into effect. Thus, assuming
you work with triplets of euler angles / velocities, this is
what you can do to make the capsule stand upright:

AV = get angular velocity
R  = get euler rotation
R += T * AV
apply torque( -R.x * C, -R.y * C, -R.z * C )

T is a time which is a tuneable (start with 0.2 seconds, perhaps)
and C is a constant that's also tuneable (start with 0.2 times

Note that this will always bring the capsule to identity position
for camera and animation work as a separate quantity, not derived
from the physics. Or you can try to preserve heading while making
the other angular values trend towards 0 using the above method.

The much more interesting method would be to actually model the
legs and torso and feet as rigid bodies, linked with joints, and
play a walking animation on the robot. The animation would effect
joints with some maximum amount of torque, and the walking/tunrning
behavior would come entirely from the physical interaction with
the ground and other obstacles.

I've been dreaming about having enough free time to actually write
exactly that, because I believe that'd make for a cool demo (I
probably won't ever have enough time to write an entire game on
my own), but, you know, time...

Cheers,

/ h+

-----Original Message-----
From: ode-bounces at q12.org [mailto:ode-bounces at q12.org]On Behalf Of Orion McClelland
Sent: Thursday, June 24, 2004 3:10 PM
To: ode at q12.org
Subject: [ODE] Using ODE to simulate a Mech game,

Hi everybody, I've been looking through the archives for a little while, and with no search function, it's a little hard to find the info I need. I am in the process of making a mech game and I'm using ODE for collision and physics. I was wondering what the best way to do this was. Currently, I just have a box around the model, and apply force to it so that it moves, but I'm having a few problems. First a mech should start and stop instantly, but friction keeps this from happening. Second, sometimes the bodies are prone to tipping when the base hits changes in elevation in the terrain. Any suggestions would be uch appreciated.

Join Excite! - http://www.excite.com
The most personalized portal on the Web!

```