Game Development Community

Bicycles / Motorcycles

by Lloyd [Bleeptech] Godsey · in Torque Game Engine · 01/20/2004 (1:35 am) · 7 replies

OK.. Here's the basic wheel datablocks for a 2 wheeled vehicle..
//I hit the 4096 char limit with the full code slice.

// This is in need of severe tuning but it proves the concept. Some values are severely
// hacked to keep the wheels on (not in) the ground and to keep it from bouncing away.

To test this create a shape with 2 hub nodes and go for a ride.
The wheels should be very narrow for this, I used 2 flat 12 sided cones base to base for the
wheels to reduce the jump/lurch when turning.
// .dts files of the test shapes I used are available on request.


//----------------------------------------------------------------------------
//         Bike.cs V0.7
//----------------------------------------------------------------------------
//    Lloyd[Bleeptech]Godsey 
//         01/20/2004 
//----------------------------------------------------------------------------
// Suspension is split to allow for using existing bikes or motorcycles as a pattern

datablock WheeledVehicleTire(DefaultBikeTire1)
{
   shapeFile = "~/data/shapes/bike/wheel.dts";
   staticFriction = 40;
   kineticFriction = 125;
   // Spring that generates lateral tire forces
   lateralForce = 2000;
   lateralDamping = 1500;
   lateralRelaxation = 0.1;
   // Spring that generates longitudinal tire forces
   longitudinalForce = 2000;
   longitudinalDamping = 1500;
   longitudinalRelaxation = 0.1;
};

datablock WheeledVehicleSpring(DefaultBikeSpring1)
{
   // Wheel suspension properties
   length = 0.6;             // Suspension travel
   force = 1500;              // Spring force
   damping = 600;             // Spring damping
   antiSwayForce = 13000;         // Lateral anti-sway force
};

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

datablock WheeledVehicleTire(DefaultBikeTire2)
{
   shapeFile = "~/data/shapes/bike/wheel.dts";
   staticFriction = 40;
   kineticFriction = 125;
   // Spring that generates lateral tire forces
   lateralForce = 2000;
   lateralDamping = 1500;
   lateralRelaxation = 0.1;
   // Spring that generates longitudinal tire forces
   longitudinalForce = 2000;
   longitudinalDamping = 1500;
   longitudinalRelaxation = 0.1;
};

datablock WheeledVehicleSpring(DefaultBikeSpring2)
{
   // Wheel suspension properties
   length = 0.6;             // Suspension travel
   force = 1500;              // Spring force
   damping = 600;             // Spring damping
   antiSwayForce = 13000;         // Lateral anti-sway force
};


Next post the main datablock.

#1
01/20/2004 (1:36 am)
Here's the main datablock for the 2 wheeler.

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

datablock WheeledVehicleData(DefaultBike)
{
   category = "Vehicles";
   shapeFile = "~/data/shapes/bike/bike.dts";
   emap = false;
   maxDamage = 1.0;
   destroyedLevel = 0.5;
   maxSteeringAngle = 0.65;  // Maximum steering angle, should match animation
   tireEmitter = TireEmitter; // All the tires use the same dust emitter
   cameraRoll = false;         // Roll the camera with the vehicle
   cameraMaxDist = 16;         // Far distance from vehicle
   cameraOffset = 4.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 = 45;  // mass * what = kilos?

   massCenter = "0 0 0";   // Center of mass for rigid body
                                // Width/Length/Height for this model
   massBox = "10 10 1";         // Size of box used for moment of inertia,
                              // if zero it defaults to object bounding box

   drag = 0.8;                // Drag coefficient
   bodyFriction = 1.9;
   bodyRestitution = 0.9;

//------------------------------------------------------------------------
// The following lines were yoinked from the Tribes 2 MPB script
// and appear to work after upping the values.
// Do these names actually mean anything to the Torque engine?

   gyroForce = 900;
   gyroDamping = 9;
   stabilizerForce = 100;

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

   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 = 1800;       // Engine power
   engineBrake = 900;         // Braking when throttle is 0
   brakeTorque = 2700;        // When brakes are applied
   maxWheelSpeed = 55;        // Engine scale by current speed / max speed

   // Energy
   maxEnergy = 10000;
   jetForce = 3000;
   minJetEnergy = 30;
   jetEnergyDrain = 2;
 };

And this is the code from my hacked vehicles.cs for setting it up.

function DefaultBike::onAdd(%this, %obj)
{
   %obj.setWheelTire(0,DefaultBikeTire1);
   %obj.setWheelSpring(0,DefaultBikeSpring1);
   %obj.setWheelTire(1,DefaultBikeTire2);
   %obj.setWheelSpring(1,DefaultBikeSpring2);

   %obj.setWheelSteering(0,1);
   %obj.setWheelSteering(1,0);

   %obj.setWheelPowered(0,false);
   %obj.setWheelPowered(1,true);
}
#2
01/20/2004 (3:24 pm)
As far as I can tell the gyroForce, gyroDamping and stabilizerForce are not implemented in any of the vehicle classes, though they are smiliar to some of the variables in the flyer and hover classes.
#3
01/20/2004 (3:31 pm)
Hmm... 1 of the 3 appeared to drop the wobble way down...
// I did a shotgun approach and added all 3 at once after trying the
// ones from the flyer example and getting nada.

I'll have to comment them out and try adding them 1 at a time..
#4
01/21/2004 (10:01 am)
None of those three items exist in the HEAD revision of the vehicle code.

Below are the items that can appear in any Vehicle Datablock

jetForce
jetEnergyDrain
minJetEnergy
massCenter
massBox
bodyRestitution
bodyFriction
softImpactSound
hardImpactSound
minImpactSpeed
softImpactSpeed
hardImpactSpeed
minRollSpeed
maxSteeringAngle
maxDrag
minDrag
integration
collisionTol
contactTol
cameraRoll
cameraLag
cameraDecay
cameraOffset
dustEmitter
triggerDustHeight
dustHeight
damageEmitter
splashEmitter
damageEmitterOffset
damageLevelTolerance
numDmgEmitterAreas
splashFreqMod
splashVelEpsilon
exitSplashSoundVelocity
softSplashSoundVelocity
mediumSplashSoundVelocity
hardSplashSoundVelocity
exitingWater
impactWaterEasy
impactWaterMedium
impactWaterHard
waterWakeSound
collDamageThresholdVel
collDamageMultiplier


Below are the items specific to each Vehicle Class

Wheeled Vehicles

Tires
shapeFile
mass
radius
staticFriction
kineticFriction
restitution
lateralForce
lateralDamping
lateralRelaxation
longitudinalForce
longitudinalDamping
logitudinalRelaxation

Springs
length
force
damping
antiSwayForce

Vehicle
jetSound
engineSound
squealSound
WheelImpactSound
tireEmitter
maxWheelSpeed
engineTorque
engineBrake
brakeTorque


Hover Vehicle

Vehicle
dragForce
vertFactor
floatingThrustFactor
mainThrustForce
reverseThrustForce
strafeThrustForce
turboFactor
stabLenMin
stabLenMax
stabSpringConstant
stabDampingConstant
gyroDrag
normalForce
restorativeForce
steeringForce
rollForce
pitchForce
jetSound
engineSound
floatSound
dustTrailEmitter
dustTrailOffset
triggerTrailHeight
dustTrailFreqMod
floatingGravMag
brakingForce
brakingActivationSpeed
forwardJetEmitter

Flying Vehicle

Vehicle
jetSound
engineSound
maneuveringForce
horizontalSurfaceForce
verticalSurfaceForce
autoInputDamping
steeringForce
steeringRollForce
rollForce
autoAngularForce
rotationalDrag
autoLinearForce
maxAutoSpeed
hoverHeight
createHoverHeight
forwardJetEmitter
backwardJetEmitter
downJetEmitter
trailEmitter
minTrailSpeed
vertThrustMultiple
#5
01/21/2004 (10:53 am)
Cool! Thanks Harold.
This is the list I was hoping to find for the vehicle nodes/emitters/physics tweak points.
The "Procto-Theological" (Pull it out of your a** and pray) method of namespace testing is a real pain and lists like this are a great help.

Hurray for LabRat! // Give him an extra farmers daughter to chase. :)
Post this one as a resource and I'll give it a 5.

All hail Mighty LabRat.. Patron saint of the caffeine deficient.. :)
#6
02/09/2006 (6:23 am)
You should take your bicycle (or any vehicles') mass into account...

http://www.garagegames.com/docs/tge/general/apds10.php

Use the starter.racing as reference, and look at the values for the buggy...

For a bicycle you would need to make the mass less... and then you would also need much less
power (torque)
#7
05/01/2009 (12:01 am)
Lloyd, Ahoy!

Remember some time back I was looking for help with the 2nd generation Charger bikes? A guy has this concept for a super efficient motor controller..."only" problem is he doesn't follow through on stuff. I'm looking for someone to make a prototype controller with the features that have been submitted to the Patent office.

Are you or someone you know able to consider time for this?

Thanks,

Sam