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

Code: [Select]
function gsfseacopterVehicle::OnTrigger(%this, %obj, %triggerNum, %val)
{
   if(%val){
      if(%triggerNum == 2){
      %pmount = %client.player.getObjectMount();
      %pmount.setVelocity("0 0 20");
 }
   }
}
The GSF sea copter has been broken for a while now, well the SetVelocity part for vertical ascent anyways.
Can anyone fix it?

Simple fix.

Replace
%pmount.setVelocity("0 0 20");
with
Code: [Select]
%vel = %pmount.getVelocity();
if(getWord(%vel,2) < 20)
%pmount.setVelocity(vectorAdd(%vel,"0 0 3");

If that's the problem you're talking about anyways.

I never used this add-on, so I'm not sure what exactly is wrong.

Simple fix.

Replace
%pmount.setVelocity("0 0 20");
with
Code: [Select]
%vel = %pmount.getVelocity();
if(getWord(%vel,2) < 20)
%pmount.setVelocity(vectorAdd(%vel,"0 0 3");

If that's the problem you're talking about anyways.

I never used this add-on, so I'm not sure what exactly is wrong.
The problem is it wasn't adding any velocity with the space bar pressed anymore.  Thanks, I'll try this.

Code: [Select]
Loading Add-On: vehicle_GSF_SeaCopter (CRC:1282198016)
Add-Ons/vehicle_GSF_SeaCopter/Vehicle_gsf_seacopter.cs Line: 229 - Syntax error.
>>> Some error context, with ## on sides of error halt:
function gsfseacopterVehicle::OnTrigger(%this, %obj, %triggerNum, %val)

{

   if(%val){

      if(%triggerNum == 2){

      %pmount = %client.player.getObjectMount();

      %vel = %pmount.getVelocity();

^if(getWord(%vel,2) < 30)

^%pmount.setVelocity(vectorAdd(%vel,"0 0 3");##
##


^  }

   }

}

datablock ParticleData(gsfseacopterParticle)

{

^windCoefficient^^= 0;

^dragCoefficient^^= 3;

^gravityCoefficient^^= 1.0;

^inheritedVelFactor^^= 0.0;

^constantAcceleration^= 0.0;

^lifetimeMS^^= 200;

^lifetimeVarianceMS^^= 200;

^textureName^^= "./blank";
>>> Error report complete.

ADD-ON "vehicle_GSF_SeaCopter" CONTAINS SYNTAX ERRORS

Throw another bracket before that semicolon. My mistake.

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

{

   if(%val)

   {

      if(%triggerNum == 2)

      {

      %pmount = %client.player.getObjectMount();

      %vel = %pmount.getVelocity();

^if(getWord(%vel,2) < 30)

^%pmount.setVelocity(vectorAdd(%vel,"0 0 3")}##;##



^  }

   }

}
« Last Edit: January 09, 2010, 04:32:03 PM by Tezuni »


« Last Edit: January 09, 2010, 05:13:49 PM by Tezuni »

%vel = %pmount.getVelocity();
if(getWord(%vel,2) < 20)
   %pmount.setVelocity(vectorAdd(%vel,"0 0 3"));

%vel = %pmount.getVelocity();
if(getWord(%vel,2) < 20)
   %pmount.setVelocity(vectorAdd(%vel,"0 0 3"));

Oh thanks.  () are parentheses btw.  and } are brackets.

My vocabulary often fails.

Code: [Select]
Add-Ons/vehicle_GSF_SeaCopter/vehicle_gsf_seacopter.cs (228): Unable to find object: '' attempting to call function 'getObjectMount'
BackTrace: ->gsfseacopterVehicle::onTrigger
I received this error when I tried using the space bar to climb vertically.  I guess it's still broke....Hmmm.
Anyone have anymore ideas?

"Fixed" Code: (Still won't climb vertically but it loads the copter now)
Code: [Select]
function gsfseacopterVehicle::OnTrigger(%this, %obj, %triggerNum, %val)
{
   if(%val)
   {
      if(%triggerNum == 2)
      {
      %pmount = %client.player.getObjectMount();
      %vel = %pmount.getVelocity();
         if(getWord(%vel,2) < 30)
%pmount.setVelocity(vectorAdd(%vel,"0 0 3"));

      }
   }
}
« Last Edit: January 09, 2010, 04:56:18 PM by Tezuni »

I just looked at that first code again...

I'm wondering where the hell %client is comming from.

I just looked at that first code again...

I'm wondering where the hell %client is comming from.
Probably the object the client is mounted to? (The Copter)

Probably the object the client is mounted to? (The Copter)
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?