Author Topic: [REQUEST]Vehicle creation tutorial  (Read 3671 times)

Can somone please make this? I would like to try making a vehicle.
« Last Edit: March 19, 2007, 03:06:44 PM by yuki »

You know putting REQUEST: in front of your topic can go a long way.

Ok i did, so can anyone diret me to or make a tutorial on making vehicles?

If you're making the model, Look at my tut here.
But since the code has more variables in retail'd, Then don't bother if you're going to code it from my tut too.

Ok, but how should i go about creating a jet?

The same way. Just with/without wheels.

Yuki is banned so he asked me to post this too:
"I created a vehicle using that tut, and when i spawn it, it crashes the entire game."

"Sorry for bump, but i need help. I created a Vehicle that runs off of the Magic Carpet script, so i made 2 seats on it with the joint names in the tut. I used the Jeep bound box, just like the magic carpet and looked through the script. When i spawn it, it crashes my game. What did i do wrong?"
CODE:
Quote
if(!isObject(jeepExplosionSound))
{
   exec("./Support_Jeep.cs");
}

datablock ExplosionData(ChopperExplosion: jeepExplosion)
{
   debrisNum = 0;
};

datablock ProjectileData(ChopperExplosionProjectile)
{
   directDamage        = 0;
   radiusDamage        = 5;
   damageRadius        = 0;
   explosion           = ChopperExplosion;

   directDamageType  = $DamageType::ChopperExplosion;
   radiusDamageType  = $DamageType::ChopperExplosion;

   explodeOnDeath      = 1;

   armingDelay         = 0;
   lifetime            = 10;
};


datablock ExplosionData(ChopperFinalExplosion)
{
     //explosionShape = "";
   lifeTimeMS = 150;

   soundProfile = jeepExplosionSound;
   
   emitter[0] = jeepFinalExplosionEmitter3;
   emitter[1] = jeepFinalExplosionEmitter2;

   particleEmitter = jeepFinalExplosionEmitter;
   particleDensity = 20;
   particleRadius = 1.0;

   debris = jeepDebris;
   debrisNum = 0;
   debrisNumVariance = 0;
   debrisPhiMin = 0;
   debrisPhiMax = 360;
   debrisThetaMin = 0;
   debrisThetaMax = 20;
   debrisVelocity = 18;
   debrisVelocityVariance = 3;

   faceViewer     = true;
   explosionScale = "1 1 1";

   shakeCamera = true;
   camShakeFreq = "7.0 8.0 7.0";
   camShakeAmp = "10.0 10.0 10.0";
   camShakeDuration = 0.75;
   camShakeRadius = 15.0;

   // Dynamic light
   lightStartRadius = 0;
   lightEndRadius = 20;
   lightStartColor = "0.45 0.3 0.1";
   lightEndColor = "0 0 0";

   //impulse
   impulseRadius = 15;
   impulseForce = 1000;
   impulseVertical = 2000;

   //radius damage
   radiusDamage        = 30;
   damageRadius        = 8.0;

   //burn the players?
   playerBurnTime = 5000;
};

datablock ProjectileData(ChopperFinalExplosionProjecti le)
{
   directDamage        = 0;
   radiusDamage        = 0;
   damageRadius        = 0;
   explosion           = ChopperFinalExplosion;

   directDamageType  = $DamageType::ChopperExplosion;
   radiusDamageType  = $DamageType::ChopperExplosion;

   explodeOnDeath      = 1;

   armingDelay         = 0;
   lifetime            = 10;
};

datablock FlyingVehicleData(ChopperVehicle)
{
   //Tagged fields for mission editor
      category = "Vehicles";
      displayName = " ";

   //Shapebase Fields
      shapeFile   = "./shapes/Chopper.dts";  //.dts File
      emap        = true;
      mass        = 200;
      drag        = 1.7;
      density     = 4;
     
      maxDamage = 100.00;
      destroyedLevel = 100.00;
      energyPerDamagePoint = 160;
      speedDamageScale = 1.04;
      collDamageThresholdVel = 20.0;
      collDamageMultiplier   = 0.02;

   //Tagged fields for mounting
      minMountDist = 3;   
      numMountPoints = 7;
      mountThread[0] = "sit";
      mountThread[1] = "sit";

   lookUpLimit = 0.75;
      lookDownLimit = 0.35;

   //Vehicle Fields:
      jetForce          = 500;
      jetEnergyDrain    = 8;
      minJetEnergy      = 1;

      massCenter        = "0 0 -1";
      //massBox           = "1 1 1";
      bodyRestitution   = 0.5;
      bodyFriction      = 0.5;
      //softImpactSound   = ; //AudioProfile
      //hardImpactSound   = ; //AudioProfile

      minImpactSpeed    = 25;
      softImpactSpeed   = 25;
      hardImpactSpeed   = 50;
      minRollSpeed      = 0;
      maxSteeringAngle  = 0.785;

      maxDrag        = 40;
      minDrag        = 50;
      integration    = 4;
      collisionTol   = 0.1;
      contactTol     = 0.1;

      cameraRoll     = false;
      cameraMaxDist  = 13;       
      cameraLag      = 0.0;
      cameraDecay    = 0.0;
      cameraOffset   = 2.5;
      cameraTilt     = 0.0;

      //dustEmitter       = ; //ParticleEmitterData
      triggerDustHeight = 3.0;
      dustHeight        = 1.0;

      numDmgEmitterAreas   = 0;
     
      damageEmitter[0] = JeepBurnEmitter;
      damageEmitterOffset[0] = "0.0 0.0 0.0 ";
      damageLevelTolerance[0] = 0.99;

      damageEmitter[1] = JeepBurnEmitter;
      damageEmitterOffset[1] = "0.0 0.0 0.0 ";
      damageLevelTolerance[1] = 1.0;

      //splashEmitter[0]        = ; //ParticleEmitterData

      splashFreqMod     = 300.0;
      splashVelEpsilon  = 0.50;

      exitSplashSoundVelocity    = 2.0;
      softSplashSoundVelocity    = 1.0;
      mediumSplashSoundVelocity  = 2.0;
      hardSplashSoundVelocity    = 3.0;
      //exitingWater               = ;   //AudioProfile
      //impactWaterEasy            = ;   //AudioProfile
      //impactWaterMedium          = ;   //AudioProfile
      //impactWaterHard            = ;   //AudioProfile
      //waterWakeSound             = ;   //AudioProfile

      collDamageThresholdVel  = 20;
      collDamageMultiplier    = 0.05;

   //For Wrench Gui
      uiName   = "Helicopter";
      rideAble = true;
      paintable = true;
      
   //Flying vehicle fields
      //jetSound = ;      //AudioProfile
      //engineSound = ;   //AudioProfile

      maneuveringForce        = 6400;
      horizontalSurfaceForce  = 20;
      verticalSurfaceForce    = 20;
      autoInputDamping        = 0.55;
      steeringForce           = 1500;
      steeringRollForce       = 200;
      rollForce               = 10;
      autoAngularForce        = 1400;
      rotationalDrag          = 20;
      autoLinearForce         = 100;
      maxAutoSpeed            = 10;
      hoverHeight             = 2.0;
      createHoverHeight       = 2.0;

      //forwardJetEmitter    = ; //ParticleEmitterData
      //backwardJetEmitter   = ; //ParticleEmitterData
      //downJetEmitter       = ; //ParticleEmitterData
      //trailEmitter         = ; //ParticleEmitterData

      minTrailSpeed        = 1;
      vertThrustMultiple   = 1.0;
   
   //Tagged fields for damage
      initialExplosionProjectile = carpetExplosionProjectile;
      initialExplosionOffset = 0;         //offset only uses a z value for now

      burnTime = 500;

      finalExplosionProjectile = carpetFinalExplosionProjectil e;
      finalExplosionOffset = 0.5;          //offset only uses a z value for now

      minRunOverSpeed    = 2;   //how fast you need to be going to run someone over (do damage)
      runOverDamageScale = 5;   //when you run over someone, speed * runoverdamagescale = damage amt
      runOverPushScale   = 1.2; //how hard a person you're running over gets pushed
};



Sorry for bump, but i really need help with this.

.... Copy both jeep.cs and the support_jeep.cs then open them and press Ctrl G then Find What: Jeep
Replace with: Name. Then Rename the .cs's...

Sorry for the bump, but i tried everything and it still crashes the game to spawn the car.
Code: [Select]
//-----------------------------------------------------------------------------

// Information extacted from the shape.
//
// Wheel Sequences
//    spring#        Wheel spring motion: time 0 = wheel fully extended,
//                   the hub must be displaced, but not directly animated
//                   as it will be rotated in code.
// Other Sequences
//    steering       Wheel steering: time 0 = full right, 0.5 = center
//    breakLight     Break light, time 0 = off, 1 = breaking
//
// Wheel Nodes
//    hub#           Wheel hub, the hub must be in it's upper position
//                   from which the springs are mounted.
//
// The steering and animation sequences are optional.
// The center of the shape acts as the center of mass for the car.

//-----------------------------------------------------------------------------
if(!isObject(DelorianExplosionSound))
{
   exec("./Support_Delorian.cs");
}
//----------------------------------------------------------------------------

datablock WheeledVehicleData(DelorianVehicle)
{
category = "Vehicles";
displayName = " ";
shapeFile = "./shapes/Delorian.dts"; //"~/data/shapes/skivehicle.dts"; //
emap = true;
minMountDist = 3;
   
   numMountPoints = 7;
   mountThread[0] = "sit";
   mountThread[1] = "sit";
   mountThread[2] = "sit";
   mountThread[3] = "sit";
   mountThread[4] = "sit";
   mountThread[5] = "root";
   mountThread[6] = "root";
   mountThread[7] = "sit";

maxDamage = 200.00;
destroyedLevel = 200.00;
energyPerDamagePoint = 160;
speedDamageScale = 1.04;
collDamageThresholdVel = 20.0;
collDamageMultiplier   = 0.02;

massCenter = "0 0 0";
   //massBox = "2 5 1";

maxSteeringAngle = 0.9785;  // Maximum steering angle, should match animation
integration = 4;           // Force integration time: TickSec/Rate
tireEmitter = TireEmitter; // All the tires use the same dust emitter

// 3rd person camera settings
cameraRoll = false;         // Roll the camera with the vehicle
cameraMaxDist = 13;         // Far distance from vehicle
cameraOffset = 7.5;        // Vertical offset from camera mount point
cameraLag = 0.0;           // Velocity lag of camera
cameraDecay = 0.75;        // Decay per sec. rate of velocity lag
cameraTilt = 0.4;
   collisionTol = 0.1;        // Collision distance tolerance
   contactTol = 0.1;

useEyePoint = false;

defaultTire = DelorianTire;
defaultSpring = DelorianSpring;
flatTire = DelorianFlatTire;
flatSpring = DelorianFlatSpring;

   numWheels = 4;

// Rigid Body
mass = 300;
density = 5.0;
drag = 1.6;
bodyFriction = 0.6;
bodyRestitution = 0.6;
minImpactSpeed = 10;        // Impacts over this invoke the script callback
softImpactSpeed = 10;       // Play SoftImpact Sound
hardImpactSpeed = 15;      // Play HardImpact Sound
groundImpactMinSpeed    = 10.0;

// Engine
engineTorque = 12000; //4000;       // Engine power
engineBrake = 2000;         // Braking when throttle is 0
brakeTorque = 50000;        // When brakes are applied
maxWheelSpeed = 30;        // Engine scale by current speed / max speed

rollForce = 900;
yawForce = 600;
pitchForce = 1000;
rotationalDrag = 0.2;

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

splash = DelorianSplash;
splashVelocity = 4.0;
splashAngle = 67.0;
splashFreqMod = 300.0;
splashVelEpsilon = 0.60;
bubbleEmitTime = 1.4;
splashEmitter[0] = DelorianFoamDropletsEmitter;
splashEmitter[1] = DelorianFoamEmitter;
splashEmitter[2] = DelorianBubbleEmitter;
mediumSplashSoundVelocity = 10.0;   
hardSplashSoundVelocity = 20.0;   
exitSplashSoundVelocity = 5.0;

//mediumSplashSound = "";
//hardSplashSound = "";
//exitSplashSound = "";

// Sounds
//   jetSound = ScoutThrustSound;
//engineSound = idleSound;
//squealSound = skidSound;
softImpactSound = slowImpactSound;
hardImpactSound = fastImpactSound;
//wheelImpactSound = slowImpactSound;

//   explosion = VehicleExplosion;
justcollided = 0;

   uiName = "Delorian ";
rideable = true;
lookUpLimit = 0.65;
lookDownLimit = 0.45;

paintable = true;
   
   damageEmitter[0] = DelorianBurnEmitter;
damageEmitterOffset[0] = "0.0 0.0 0.0 ";
damageLevelTolerance[0] = 0.99;

   damageEmitter[1] = DelorianBurnEmitter;
damageEmitterOffset[1] = "0.0 0.0 0.0 ";
damageLevelTolerance[1] = 1.0;

   numDmgEmitterAreas = 1;

   initialExplosionProjectile = DelorianExplosionProjectile;
   initialExplosionOffset = 0;         //offset only uses a z value for now

   burnTime = 4000;

   finalExplosionProjectile = DelorianFinalExplosionProjectile;
   finalExplosionOffset = 0.5;          //offset only uses a z value for now


   minRunOverSpeed    = 2;   //how fast you need to be going to run someone over (do damage)
   runOverDamageScale = 5;   //when you run over someone, speed * runoverdamagescale = damage amt
   runOverPushScale   = 1.2; //how hard a person you're running over gets pushed
};





That's the support, heres the vehicle:
Code: [Select]
//-----------------------------------------------------------------------------

// Information extacted from the shape.
//
// Wheel Sequences
//    spring#        Wheel spring motion: time 0 = wheel fully extended,
//                   the hub must be displaced, but not directly animated
//                   as it will be rotated in code.
// Other Sequences
//    steering       Wheel steering: time 0 = full right, 0.5 = center
//    breakLight     Break light, time 0 = off, 1 = breaking
//
// Wheel Nodes
//    hub#           Wheel hub, the hub must be in it's upper position
//                   from which the springs are mounted.
//
// The steering and animation sequences are optional.
// The center of the shape acts as the center of mass for the car.

//-----------------------------------------------------------------------------
if(!isObject(DelorianExplosionSound))
{
   exec("./Support_Delorian.cs");
}
//----------------------------------------------------------------------------

datablock WheeledVehicleData(DelorianVehicle)
{
category = "Vehicles";
displayName = " ";
shapeFile = "./shapes/Delorian.dts"; //"~/data/shapes/skivehicle.dts"; //
emap = true;
minMountDist = 3;
   
   numMountPoints = 7;
   mountThread[0] = "sit";
   mountThread[1] = "sit";
   mountThread[2] = "sit";
   mountThread[3] = "sit";
   mountThread[4] = "sit";
   mountThread[5] = "root";
   mountThread[6] = "root";
   mountThread[7] = "sit";

maxDamage = 200.00;
destroyedLevel = 200.00;
energyPerDamagePoint = 160;
speedDamageScale = 1.04;
collDamageThresholdVel = 20.0;
collDamageMultiplier   = 0.02;

massCenter = "0 0 0";
   //massBox = "2 5 1";

maxSteeringAngle = 0.9785;  // Maximum steering angle, should match animation
integration = 4;           // Force integration time: TickSec/Rate
tireEmitter = TireEmitter; // All the tires use the same dust emitter

// 3rd person camera settings
cameraRoll = false;         // Roll the camera with the vehicle
cameraMaxDist = 13;         // Far distance from vehicle
cameraOffset = 7.5;        // Vertical offset from camera mount point
cameraLag = 0.0;           // Velocity lag of camera
cameraDecay = 0.75;        // Decay per sec. rate of velocity lag
cameraTilt = 0.4;
   collisionTol = 0.1;        // Collision distance tolerance
   contactTol = 0.1;

useEyePoint = false;

defaultTire = DelorianTire;
defaultSpring = DelorianSpring;
flatTire = DelorianFlatTire;
flatSpring = DelorianFlatSpring;

   numWheels = 4;

// Rigid Body
mass = 300;
density = 5.0;
drag = 1.6;
bodyFriction = 0.6;
bodyRestitution = 0.6;
minImpactSpeed = 10;        // Impacts over this invoke the script callback
softImpactSpeed = 10;       // Play SoftImpact Sound
hardImpactSpeed = 15;      // Play HardImpact Sound
groundImpactMinSpeed    = 10.0;

// Engine
engineTorque = 12000; //4000;       // Engine power
engineBrake = 2000;         // Braking when throttle is 0
brakeTorque = 50000;        // When brakes are applied
maxWheelSpeed = 30;        // Engine scale by current speed / max speed

rollForce = 900;
yawForce = 600;
pitchForce = 1000;
rotationalDrag = 0.2;

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

splash = DelorianSplash;
splashVelocity = 4.0;
splashAngle = 67.0;
splashFreqMod = 300.0;
splashVelEpsilon = 0.60;
bubbleEmitTime = 1.4;
splashEmitter[0] = DelorianFoamDropletsEmitter;
splashEmitter[1] = DelorianFoamEmitter;
splashEmitter[2] = DelorianBubbleEmitter;
mediumSplashSoundVelocity = 10.0;   
hardSplashSoundVelocity = 20.0;   
exitSplashSoundVelocity = 5.0;

//mediumSplashSound = "";
//hardSplashSound = "";
//exitSplashSound = "";

// Sounds
//   jetSound = ScoutThrustSound;
//engineSound = idleSound;
//squealSound = skidSound;
softImpactSound = slowImpactSound;
hardImpactSound = fastImpactSound;
//wheelImpactSound = slowImpactSound;

//   explosion = VehicleExplosion;
justcollided = 0;

   uiName = "Delorian ";
rideable = true;
lookUpLimit = 0.65;
lookDownLimit = 0.45;

paintable = true;
   
   damageEmitter[0] = DelorianBurnEmitter;
damageEmitterOffset[0] = "0.0 0.0 0.0 ";
damageLevelTolerance[0] = 0.99;

   damageEmitter[1] = DelorianBurnEmitter;
damageEmitterOffset[1] = "0.0 0.0 0.0 ";
damageLevelTolerance[1] = 1.0;

   numDmgEmitterAreas = 1;

   initialExplosionProjectile = DelorianExplosionProjectile;
   initialExplosionOffset = 0;         //offset only uses a z value for now

   burnTime = 4000;

   finalExplosionProjectile = DelorianFinalExplosionProjectile;
   finalExplosionOffset = 0.5;          //offset only uses a z value for now


   minRunOverSpeed    = 2;   //how fast you need to be going to run someone over (do damage)
   runOverDamageScale = 5;   //when you run over someone, speed * runoverdamagescale = damage amt
   runOverPushScale   = 1.2; //how hard a person you're running over gets pushed
};






Most likely your model, Scripts can't really crash the game only the model.
Make sure you wheels go under the collision and when the Vehicle Bounces the collision doesn't hit the ground.

In neither of them scripts do you actually define 'DelorianExplosionSound' so the script keeps on looping. Forever and crashing. Change it to JeepExplosionSound or actually define the sound.

Most likely your model, Scripts can't really crash the game only the model.
Make sure you wheels go under the collision and when the Vehicle Bounces the collision doesn't hit the ground.
Then a vehicle model tut?
In neither of them scripts do you actually define 'DelorianExplosionSound' so the script keeps on looping. Forever and crashing. Change it to JeepExplosionSound or actually define the sound.
I'll try.

Can anyone post a vehicle creation tut?