Author Topic: Adding Velocity To a Vehicle (SetVelocity)  (Read 1420 times)

I don't see where %client is defined.

Code: [Select]
function gsfseacopterVehicle::OnTrigger(%this, %obj, %triggerNum, %val)
{
   if(%val){
      if(%triggerNum == 2){

Do you see %client being defined anywhere?
Nope, but the strange thing is the original code used to work.  I think the updates in v13 caused this to break.

I don't see how it worked in the first place.

I don't see how it worked in the first place.
Can we just define %client then?  Are you out of ideas? D:

I would rewrite the entire thing.

I would rewrite the entire thing.
Will you? :o
I have no idea to begin.  Anyways, your help has been much appreciated...and anymore would be too...

I would have to be home where I have Blockland, where I get all my resources.

Since it's the datablock, would %obj not be the vehicle calling it?
Code: [Select]
function gsfseacopterVehicle::OnTrigger(%this, %obj, %triggerNum, %val)
{
   if(%val)
   {
      if(%triggerNum == 2)
      {
         %vel = %obj.getVelocity();
         if(getWord(%vel,2) < 30)
    %obj.setVelocity(vectorAdd(%vel,"0 0 3"));

      }
   }
}
Though I'm not entirely sure that vehicles call ontrigger when the pilot does anyway, so:
Code: [Select]
package SeaCopterTrigger
{
   function Armor::onTrigger(%datablock,%player,%slot,%val)
   {
      Parent::onTrigger(%datablock,%player,%slot,%val);
      %mount = %player.getObjectMount();
      if(%slot == 2 && isObject(%mount))
      {
         if(%val)
         {
            %mountdatablock = %mount.getDatablock();
            if(%mountdatablock.getName() $= "GSFSeaCopterVehicle")
            {
               %mountdatablock.climbUp(%mount);
            }
         } else {
            cancel(%mount.climbUpSchedule);
         }
      }
   }
};
ActivatePackage(SeaCopterTrigger);
function GSFSeaCopterVehicle::climbUp(%datablock,%vehicle)
{
   %vel = %vehicle.getVelocity();
   if(getWord(%vel,2) < 20)
   {
      %vehicle.setVelocity(vectorAdd(%vel,"0 0 1"));
   }
   %vehicle.climbUpSchedule = %datablock.schedule(50,"climbUp",%vehicle);
}
110% untested but theoretically works provided I didn't make a silly syntax error somewhere.

110% untested but theoretically works provided I didn't make a silly syntax error somewhere.
It has no syntax errors, however, it doesn't seem to work.  It doesn't add any velocity or anything, hmmm I wonder what went wrong?