Game Development Community

Vehicle weight, torque, max speed

by David Erenger · in Torque Game Engine · 03/11/2004 (7:06 am) · 13 replies

If I have a vehicle that weight 4400 kg has a max speed of 70km/h and the engine have 117 hp, and 206Nm...

how can I set engineTorque, mass and maxWheelSpeed to the right value??

I'v tried a lot different calculations but nothing seems right.

And also, how can I keep the vehicle down when it have fellt over, now its like whenever a wheel touch the ground it will stand up again in a very unrealistic flip???

thanks
// David

#1
03/11/2004 (9:24 am)
I don't know what the real world units compared to torque units are. However, the bouncing can be a result of several different variables. The springs on your wheels can cause your vehicle to bounce too much. So you can play with the spring length, the spring force and the damping to try to fix it. Changing the integration variable will also affect all your numbers (less integration tends to 'cause more bounciness, more integration less; however, more integration takes up more CPU).

That's sort of a summary of the vehicle physics as I understand them from experimentation...hopefully that'll give you a place to start.

One thing I found very helpful was to create a GUI that allows you to change these variable in game, just requiring a respawn of your vehicle for them to take effect instead of having to restart the whole game. There might be a resource for that somewhere on GarageGames, but if not, I can pull out the one I wrote for my game.

-Rob
#2
03/11/2004 (9:32 am)
Ok thanks that would be extremly valueble, I hate to restart the mission everytime I need to try another number in the script.

is it small? can you post it here? that would be very nice

thanks
#3
03/11/2004 (9:54 am)
Check out this resource and see if that helps you. I'll work on putting together my version in case that resource doesn't help you (it'll take a little work for me to get it together...Ihave to go back and remember exactly what I did ;).

-Rob
#4
03/11/2004 (10:03 am)
A five ton vehicle with 117 horsepower? Could there ever be such a thing?

Just an observation, but I'm pretty sure in real world physics such a vehicle wouldn't go uphill at all and maybe just crawl on level ground. It would have to have tiny wheels, also.
#5
03/11/2004 (10:08 am)
Alright, I gathered up all the files required. I'll just email it to you with install instructions.

-Rob
#6
03/11/2004 (10:27 am)
Well, so the email didn't work . . . I'll just post it here.

This is somewhat simple, though it requires touching a few files:

1. Open up the .zip and place the files in the following locations:

-carDataDlg.gui goes in //client/ui
-dynamic_car.cs goes in //server/scripts

2. Open up //client/init.cs and add this line of code with the rest of the gui execs:

exec("./ui/carDataDlg.gui");

3. Open up //server/defaults.cs and add the default values for all your variables. Here's a list of them that'll make it easier, just change the numbers to the settings you currently have in your car.cs file:

$Pref::staticFriction = 9;
   $Pref::kineticFriction = 7;
   $Pref::lateralForce = 18000;
   $Pref::lateralDamping = 4000;
   $Pref::lateralRelaxation = 1;
   $Pref::longitudinalForce = 18000;
   $Pref::longitudinalDamping = 4000;
   $Pref::longitudinalRelaxation = 1;
   $Pref::length = 0.08;             // Suspension travel
   $Pref::force = 8000;              // Spring force
   $Pref::damping = 200;             // Spring damping
   $Pref::antiSwayForce = 5;         // Lateral anti-sway force
   $Pref::maxDamage = 1.0;
   $Pref::destroyedLevel = 0.5;
   $Pref::maxSteeringAngle = 0.57;  // Maximum steering angle, should match animation
   $Pref::cameraRoll = true;         // Roll the camera with the vehicle
   $Pref::cameraMaxDist = 6;         // Far distance from vehicle
   $Pref::cameraOffset = 1.5;        // Vertical offset from camera mount point
   $Pref::cameraLag = 0.1;           // Velocity lag of camera
   $Pref::cameraDecay = 0.75;        // Decay per sec. rate of velocity lag
   $Pref::mass = 100;
   $Pref::massCenter = "0 0 0";    // Center of mass for rigid body
   $Pref::massBox = "0 0 0";         // Size of box used for moment of inertia,
   $Pref::drag = 0.9;                // Drag coefficient
   $Pref::bodyFriction = 0.6;
   $Pref::bodyRestitution = 0.2;
   $Pref::minImpactSpeed = 15;        // Impacts over this invoke the script callback
   $Pref::softImpactSpeed = 15;       // Play SoftImpact Sound
   $Pref::hardImpactSpeed = 40;      // Play HardImpact Sound
   $Pref::integration = 12;           // Physics integration: TickSec/Rate
   $Pref::collisionTol = 0.4;        // Collision distance tolerance
   $Pref::contactTol = 0.08;          // Contact velocity tolerance
   $Pref::engineTorque = 25000;       // Engine power
   $Pref::engineBrake = 3000;         // Braking when throttle is 0
   $Pref::brakeTorque = 10000;        // When brakes are applied
   $Pref::maxWheelSpeed = 145;        // Engine scale by current speed / max speed
   $Pref::maxEnergy = 100;
   $Pref::jetForce = 3000;
   $Pref::minJetEnergy = 30;
   $Pref::jetEnergyDrain = 2;
   $Pref::FRSteering = 1;  // steering for the Front Right wheel 
   $Pref::FLSteering = 1;  // (can be 1, 0 (no steering), or -1 (inverted steering)
   $Pref::RRSteering = 0;
   $Pref::RLSteering = 0;
   $Pref::FRPower = 1;  // determines whether the wheel is powered or not (1 has power, 0 doesn't)
   $Pref::FLPower = 1;
   $Pref::RRPower = 0;
   $Pref::RLPower = 0;

3. Open up //server/scripts/game.cs and locate the exec calls near the top of the file and add one for the dynamic_car.cs file:

exec("./dynamic_car.cs");

4. Check dynamic_car.cs to be sure the datablocks are named correctly and the associated models are pointing to the right places (I don't remember what all those things were from the racing mod).

5. Open up //client/scripts/default.bind.cs and add this code to the file somewhere:

function bringUpCarData(%val)
    {
       if (%val)
          Canvas.pushDialog(carDataDlg);
    }
    
    moveMap.bind(keyboard, "ctrl d", bringUpCarData);

I think that should be everything. Let me know if you need any other help with it.

Peace,
-Rob

[edit: formatting]
#7
03/13/2004 (2:46 am)
@michael http://www.soldf.com/tgb11.html check out this swedish army car, I'm creating a game with swedish military, and so it says :)...

@Robert Nall

thanks man, I'll check it out right now, I think thats an extremly cool resource that will make it a lot easer to configure my cars :)... thanks
#8
06/17/2004 (4:23 am)
Hi I was wondering where I can get that .Zip file as the old link seems to be dead :(

I am working on a racing game and this sounds like it would help me out alot.

-Fritz M.
#9
07/07/2004 (2:08 am)
Me too.
Can you please Robert re-link the .Zip file
THX ALOT
Andrea
#10
08/31/2004 (1:48 pm)
Sorry guys, I forgot what those files were and had deleted them off my server AND I didn't have this thread on notify so I didn't realize there were any responses . . . anyway, I've updated the link above and for your convenience, I'm adding it again right here: enjoy ^_^

-rob

[edit: heh heh . . . might work better if the link were CORRECT ; ) ]
#11
08/31/2004 (2:00 pm)
Oh, forgot . . . the scripts are updated as well to allow for tweaking of front and rear suspension seperately. So you'll need to add the defaults for the rear suspension in the same place as the other defaults (see above). Here's your copy-paste versions:

$Pref::rear::staticFriction = 20;
   $Pref::rear::kineticFriction = 19;
   $Pref::rear::lateralForce = 70000;
   $Pref::rear::lateralDamping = 1000;
   $Pref::rear::lateralRelaxation = 1;
   $Pref::rear::longitudinalForce = 6000;
   $Pref::rear::longitudinalDamping = 900;
   $Pref::rear::longitudinalRelaxation = 1;
   $Pref::rear::length = 0.2;             // Suspension travel
   $Pref::rear::force = 8000;              // Spring force
   $Pref::rear::damping = 460;             // Spring damping
   $Pref::rear::antiSwayForce = 1;         // Lateral anti-sway force

-rob

[edit: typo]
#12
04/19/2005 (4:32 pm)
Don't forget to comment out your old car.cs file, and in the bottom of carDataDlg.gui,

change 
exec("rcm_base/server/scripts/test_car.cs"); 
to 
exec("<yourmod>/server/scripts/dynamic_car.cs");

Great resource btw.
#13
04/19/2005 (4:45 pm)
@Boni: Good catch. And glad ya find it useful!