Game Development Community

Car slipping / turning at 65 mph and above

by Chris Newman · in Torque Game Engine · 11/07/2004 (8:27 am) · 45 replies

When the speedo hit 65 my car starts to slip to the left or right. It refuses to stay in a straght line above these speeds.

I have completely flat terrain and the only data block setting i changed to cause this was the maxWheelSpeed. I changed that to 70.

I tried tweaking other settings but nothing seems to help it at all.

Ive noticed other racing games have cars at high speeds and from the videos they did not have this problem.
#21
10/16/2005 (1:57 pm)
Thanks for the help, Akio, but where exactly is our pivot point supposed to be and how do I find out?
#22
10/16/2005 (2:10 pm)
When you create your vehicle in your 3D modeling app, you have to create the 'bounds' to be able to export the DTS file. When this bounds is created, the pivot point is typically placed at the bottom center of your object. Using a move tool should show you where your drag point is, and this is your pivot point. Adjust this point to the center of the bounds. Different 3D modeling apps have different methods and you'll have to figure out how to do that.
#23
11/10/2005 (11:13 pm)
After MUCH trial and error I've finally hit upon some decent arcade style car handling configuration. Nothing fancy here, but the vehicle drives in a straight line at high speeds, turns well, never seems to flip and skids fairly well when turning. I'll post my settings here in case anyone else finds this useful.

Two imporant things to note: The vehicle is front wheel drive and the mass center is 0 0 -0.7. Also, this is based entirely on the buggy demo. Nothing else has been changed, except that I've implemented a bit of code to return the front tires to the center when the keyboard is released.

(Edit: Out of space. I'll do two posts.)
#24
11/10/2005 (11:14 pm)
Datablock WheeledVehicleTire(DefaultCarTire)
{
// Tires act as springs and generate lateral and longitudinal
// forces to move the vehicle. These distortion/spring forces
// are what convert wheel angular velocity into forces that
// act on the rigid body.
shapeFile = "~/data/shapes/buggy/wheel.dts";
staticFriction = 4.5;
kineticFriction = 2;

// Spring that generates lateral tire forces
lateralForce = 8000;
lateralDamping = 40;
lateralRelaxation = 1;

// Spring that generates longitudinal tire forces
longitudinalForce = 8000;
longitudinalDamping = 40;
longitudinalRelaxation = 1;
};

datablock WheeledVehicleSpring(DefaultCarSpring)
{
// Wheel suspension properties
length = 0.85; // Suspension travel
force = 3000; // Spring force
damping = 600; // Spring damping
antiSwayForce = 3; // Lateral anti-sway force
};

datablock WheeledVehicleData(DefaultCar)
{
category = "Vehicles";
shapeFile = "~/data/shapes/buggy/buggy.dts";
emap = true;

maxDamage = 1.0;
destroyedLevel = 0.5;

maxSteeringAngle = 0.785; // Maximum steering angle, should match animation
tireEmitter = TireEmitter; // All the tires use the same dust emitter

// 3rd person camera settings
cameraRoll = true; // Roll the camera with the vehicle
cameraMaxDist = 6; // Far distance from vehicle
cameraOffset = 1.5; // Vertical offset from camera mount point
cameraLag = 0.05; // Velocity lag of camera
cameraDecay = 0.75; // Decay per sec. rate of velocity lag

// Rigid Body
mass = 200;
//massCenter = "0 -0.5 0"; // Center of mass for rigid body
massCenter = "0 0 -0.7"; // Center of mass for rigid body
massBox = "0 0 0"; // Size of box used for moment of inertia,
// if zero it defaults to object bounding box
drag = 0.6; // Drag coefficient
bodyFriction = 0.6;
bodyRestitution = 0.4;
minImpactSpeed = 5; // Impacts over this invoke the script callback
softImpactSpeed = 5; // Play SoftImpact Sound
hardImpactSpeed = 15; // Play HardImpact Sound
integration = 4; // Physics integration: TickSec/Rate
collisionTol = 0.1; // Collision distance tolerance
contactTol = 0.1; // Contact velocity tolerance

// Engine
engineTorque = 4000; // Engine power
engineBrake = 600; // Braking when throttle is 0
brakeTorque = 8000; // When brakes are applied
maxWheelSpeed = 80; // Engine scale by current speed / max speed

// Energy
maxEnergy = 100;
jetForce = 3000;
minJetEnergy = 30;
jetEnergyDrain = 2;

// Sounds
// jetSound = ScoutThrustSound;
// engineSound = BuggyEngineSound;
// squealSound = ScoutSquealSound;
// softImpactSound = SoftImpactSound;
// hardImpactSound = HardImpactSound;
// wheelImpactSound = WheelImpactSound;

// explosion = VehicleExplosion;
};


//-----------------------------------------------------------------------------

function WheeledVehicleData::create(%block)
{
%obj = new WheeledVehicle() {
dataBlock = %block;
};
return(%obj);
}

//-----------------------------------------------------------------------------

function WheeledVehicleData::onAdd(%this,%obj)
{
// Setup the car with some defaults tires & springs
for (%i = %obj.getWheelCount() - 1; %i >= 0; %i--) {
%obj.setWheelTire(%i,DefaultCarTire);
%obj.setWheelSpring(%i,DefaultCarSpring);
%obj.setWheelPowered(%i,false);
}

// Steer front tires
%obj.setWheelSteering(0,1);
%obj.setWheelSteering(1,1);

// Only power the two rear wheels...
%obj.setWheelPowered(0,true);
%obj.setWheelPowered(1,true);
// %obj.setWheelPowered(2,true);
// %obj.setWheelPowered(3,true);
}
#25
11/10/2005 (11:28 pm)
Thank you I'll try this right now.

Edit: I like these settings alot better than the starter.racing settings. It's nice to finally be able to slide around corners with a WheeledVehicle =). There seems to be a problem with the car shaking around when it's just sitting still. (in 1.4rc2)
#26
11/11/2005 (4:14 am)
That's 65 metres per second, not mph, of course.. not that it's relevant to anything! :-)
#27
11/14/2005 (7:06 pm)
I haven't noticed that Midhir. I'm using 1.3, though. I didn't even know there was a version 1.4rc2. I'll go check the downloads section.
#28
03/29/2006 (4:52 am)
@Sam: How to calcule distance we are running?

S=vt; // M/S , each second increase metres?
#29
07/01/2007 (8:30 pm)
I tried these settings with TGE 1.5.2 because I am getting the same high speed problems as in the post. I get the same shaking/swaying effect as giving to Midhir. No idea what causes it yet though. Now for those interested I did orginally test this with my version of the code, then with the stock version to get the exact same effect.

Has anyone come to a solution on this? if so would you please share it, this thread is kind of old and for the same problem to be there is not good.

I even made a video from the City Pack that helps really illustrate what is going on.

Click on the picture below to see the video.

i72.photobucket.com/albums/i192/DTDA/th_Wierdvehicle.jpg
#30
07/02/2007 (12:15 am)
It looks like your springs are too weak, or your mass is too high.
#31
07/02/2007 (12:22 am)
OK thats easy enough to change. But even with stock spring and wheel settings if the car goes to fast it won't stick to traveling in a straight line but starts sliding and turning.

I still want to be able to allow that kind of sliding when I am actually turning the vehicle, but not when I am just going straight.

Any suggestions? Basically I am trying to set up the suspension system for a late model hotrod. I guess I could really use a good working example.
#32
07/02/2007 (12:23 am)
I've got a vehicle that can turbo boost to just over 100km/h and I've never had any of the problems being discussed here. I think the trick to it is a well balanced vehicle datablock/spring and suspension settings.
#33
07/02/2007 (12:25 am)
Again since this isn't really my area yet, I guess I need to get an example or can someone tell me how the wheel and spring settings compare to an actual vehicle's characteristics?
#34
07/02/2007 (12:31 am)
When I get home I'll upload a video and post an excellent sample datablock that you can use as a base.

The trick is to make minor adjustments and to realize that a car (in real life) isn't all that stable at high speeds. To an extent, the vehicle physics in Torque try to emulate this and you have to account for it.
#35
07/02/2007 (1:04 am)
Season to taste:
datablock WheeledVehicleTire(carTire)
{
   // Tires act as springs and generate lateral and longitudinal
   // forces to move the vehicle. These distortion/spring forces
   // are what convert wheel angular velocity into forces that
   // act on the rigid body.
   shapeFile              = "~/data/shapes/car/car_tire.dts";
   staticFriction         = 4;
   kineticFriction        = 1.25;
   //
   // Spring that generates lateral tire forces
   lateralForce           = 6000;
   lateralDamping         = 400;
   lateralRelaxation      = 1;
   //
   // Spring that generates longitudinal tire forces
   longitudinalForce      = 6000;
   longitudinalDamping    = 400;
   longitudinalRelaxation = 1;
};

datablock WheeledVehicleSpring(carSpring)
{
   // Wheel suspension properties
   length        = 0.25; // Suspension travel
   force         = 3000; // Spring force
   damping       = 1200; // Spring damping
   antiSwayForce = 5;    // Lateral anti-sway force
};


datablock WheeledVehicleData(Car)
{
   category                 = "Vehicles";
   shapeFile                = "~/data/shapes/car/car.dts";
   emap                     = true;
   //
   // 3rd person camera settings
   cameraRoll               = true;        // Roll the camera with the vehicle
   cameraMaxDist            = 8;           // Far distance from vehicle
   cameraOffset             = 1.5;         // Vertical offset from camera mount point
   cameraLag                = 0.1;         // Velocity lag of camera
   cameraDecay              = 0.75;        // Decay per sec. rate of velocity lag
   //
   // Rigid Body
   mass                     = 400;
   massCenter               = "0 -0.5 0";  // Center of mass for rigid body
   massBox                  = "0 0 0";     // Size of box used for moment of inertia,
   //                                        // if zero it defaults to object bounding box
   drag                     = 0.6;
   bodyFriction             = 0.6;
   bodyRestitution          = 0.4;
   minImpactSpeed           = 5;           // Impacts over this invoke the script callback
   softImpactSpeed          = 5;           // Play SoftImpact Sound
   hardImpactSpeed          = 15;          // Play HardImpact Sound
   integration              = 4;           // Physics integration: TickSec/Rate
   collisionTol             = 0.1;         // Collision distance tolerance
   contactTol               = 0.1;         // Contact velocity tolerance
   //
   // Engine
   engineTorque             = 5000;        // Engine power
   engineBrake              = 1000;        // Braking when throttle is 0
   brakeTorque              = 10000;       // When brakes are applied
   maxWheelSpeed            = 17.5;        // Engine scale by current speed / max speed
   //
   // Energy
   maxEnergy                = 500;
   jetForce                 = 5000;
   jetEnergyDrain           = 5;
   minJetEnergy             = 50;
   rechargeRate             = 1;
   //
   // Sounds
   engineSound              = humveeEngineSound;
   jetSound                 = humveeTurboSound;
   squealSound              = humveeSquealSound;
   softImpactSound          = SoftImpactSound;
   hardImpactSound          = HardImpactSound;
   wheelImpactSound         = WheelImpactSound;
   //
   // Damage emitters, explosions and debris
   damageEmitter[0]         = LightDamageSmoke;
   damageEmitter[1]         = HeavyDamageSmoke;
   //
   damageEmitterOffset[0]   = "0 2.5 -0.5";
   damageEmitterOffset[1]   = "0 2 -2";
   //
   damageLevelTolerance[0]  = 0.3;
   damageLevelTolerance[1]  = 0.7;
   //
   numDmgEmitterAreas = 2;
   //
   explosion                = GenericLargeExplosion;
   //
   debrisShapeName          = "~/data/shapes/car/car_debris.dts";
   debris                   = ShapeDebris;
   //
   useEyePoint              = true;
   renderWhenDestroyed      = false;
};

function WheeledVehicleData::onAdd(%this,%obj)
{
   // Setup the car with some defaults tires & springs
   for (%i = %obj.getWheelCount() - 1; %i >= 0; %i--) {
      %obj.setWheelTire(%i,carTire);
      %obj.setWheelSpring(%i,carSpring);
      %obj.setWheelPowered(%i,false);
   }
   //
   // Steer front tires
   %obj.setWheelSteering(0,1);
   %obj.setWheelSteering(1,1);
   //
   // power all 4 wheels...
   %obj.setWheelPowered(0,true); // front left
   %obj.setWheelPowered(1,true); // front right
   %obj.setWheelPowered(2,true); // rear left
   %obj.setWheelPowered(3,true); // rear right
   //
   %obj.setRechargeRate(%this.rechargeRate);
   %obj.setEnergyLevel(%this.MaxEnergy);
   %obj.setRepairRate(0);
   %obj.mountable = true;
}
For greatly improved steering, open wheeledVehicle.cc and alter the updateMove function to this:
void WheeledVehicle::updateMove(const Move* move)
{
   Parent::updateMove(move);

   // Break on trigger
   mBraking = move->trigger[4];// shift handbrake to trigger 4 so we can still use jump sentinel

   // Set the tail brake light thread direction based on the brake state.
   if (mTailLightThread)
      mShapeInstance->setTimeScale(mTailLightThread,mBraking? 1: -1);

   // Steering return-to-center
	F32 returnSpeed = mFabs( move->y * .04 ); // based on forward/backward motion

	if( mSteering.x > 0 )
	{
		mSteering.x -= returnSpeed;
		if (mSteering.x < 0) mSteering.x = 0;
	}
	else if( mSteering.x < 0 )
	{
		mSteering.x += returnSpeed;
		if (mSteering.x > 0) mSteering.x = 0;
	}

	if( mSteering.y > 0 )
	{
		mSteering.y -= returnSpeed;
		if (mSteering.y < 0) mSteering.y = 0;
	}
	else if( mSteering.y < 0 )
	{
		mSteering.y += returnSpeed;
		if (mSteering.y > 0) mSteering.y = 0;
	}
	// End steering return-to-center code
}
#36
07/02/2007 (5:33 pm)
Thanks Tim but this one does the same thing. Oh and I already had the Jacoby code in my version. But thanks man.

First I agree with you about instability at high speeds, but only to an extent. As you have seen at any drag strip as long as you don't steer, typical you can reach very high speeds without an issue.

I just need a setup that can comfortably hit speeds on a straight-away of 100 to 140 MPH. However, it should also be able to go around a track and drift. These are characteristic of a "real" car. Not a "suped" up machine or any high performance vehicle, but a real every day car can do these things.

This is why I feel there is a problem, this should be able to handle the driving specs of a very normal car. I don't know of any car that slides out of control when you reach speeds over 65 MPH. Not unless its got soething wrong with it.
#37
07/05/2007 (4:06 pm)
GAH!!!!!!! I have to ask because frankly guess over and over is really getting aggravating. Is there some sort of formula that accurately explains how TGE does it's vehicle chassis-spring-wheel system so I can determine what is a godd system for high speeds or what would be best for low speed offroad vehicles?
#38
10/26/2007 (3:38 pm)
Thanks much for this tip =)
#39
10/26/2007 (5:35 pm)
Using starter.racing, I changed two lines to get control of my car.

massCenter               = "0 -0.5 0";  // Center of mass for rigid body
changed to:
massCenter               = "0 -0.5 0.2";  // Center of mass for rigid body

and changed the powered wheels to the front wheels. That worked great. I can get to 100mph without sliding from side to side.
#40
10/29/2007 (11:24 pm)
Mike,

How did you change the powered wheels to be the front wheels? I poked through car.cs, and didn't see any obvious way to do it there.