Author Topic: Making function onDriverEnter as a mirror to onDriverLeave  (Read 2459 times)

You need to package that one, so it calls the original WheeledVehicleData::onAdd.

This function in Vehicle_Tank.cs isn't packaged.
(I don't mean to be argumentative, only to understand this apparent contradiction)

Code: [Select]
function TankVehicle::onAdd(%this,%obj)
{
   // Setup the car with some defaults tires & springs
   for(%i = 0; %i < %this.numWheels; %i++)
   {
      %obj.setWheelTire(%i, %this.defaultTire);
      %obj.setWheelSpring(%i, %this.defaultSpring);
   }

   // 4 wheel steering
   %obj.setWheelSteering(0,1);
   %obj.setWheelSteering(1,1);
   %obj.setWheelSteering(2,-0.8);
   %obj.setWheelSteering(3,-0.8);

   // 4 wheel drive
   %obj.setWheelPowered(0,true);
   %obj.setWheelPowered(1,true);
   %obj.setWheelPowered(2,true);
   %obj.setWheelPowered(3,true);

   // turret
   %t = new AIPlayer()
   {
      dataBlock = TankTurretPlayer;
   };
   if(isObject(%t)) //creation can fail due to quota limit
   {
      MissionCleanup.add(%t);
      %obj.mountObject(%t, 2);
      %obj.turret = %t;
      %t.schedule(10,"rigTurret");
   }

   %obj.creationTime = getSimTime();     
}

...OH

Is it not parenting onAdd because it does everything TankVehicle::onAdd would do, down to default tires and springs, and setting every wheel to be powered?


Aha! The answer is a resounding yes.

« Last Edit: March 31, 2016, 12:38:14 PM by Teneksi »

You do not need the parent for custom datablocks ::onAdd.
« Last Edit: March 31, 2016, 08:24:18 PM by Kyuande »

You do not need the parent for custom datablocks ::onAdd.
The above picture is what happens when I don't

Turns out I'm most likely wrong, you need to add the parent, but, if you're not going to do anything special with the vehicle don't use ::onAdd.

Turns out I'm most likely wrong, you need to add the parent, but, if you're not going to do anything special with the vehicle don't use ::onAdd.
oh man i'm doing all sorts of special stuff

just add the parent on the datablock name and then do your stuff