Author Topic: How do you change only part of the velocity?  (Read 638 times)

For a current weapon I am trying to make it so when you fire you stop moving in the X and Y axis but you are still able to fall at the same speed.
I have tried:
Code: [Select]
function WeaponImage::onFire(%this,%obj,%slot)
{
%playervelocity = %obj.getvelocity()
%pvX = (getWord(%playervelocity, 0)) * 0.5;
%pvY = (getWord(%playervelocity, 1)) * 0.5;
%pvZ = getword(%playervelocity, 2);
%obj.setvelocity() = (%pvx @ " " @ %pvy @ " " @ %pvz);
}
But obviously I am doing something wrong as I keep getting syntax errors.
Does anyone know what I am doing wrong?

So you want to cancel all movement on the X and Y and keep the Z velocity? Use this:

Code: [Select]
function WeaponImage::onFire(%this,%obj)
{
     %obj.setVelocity("0 0" SPC getWord(%obj.getVelocity(),2));
}


Ah ok. See, I just over complicate thigns don't I.
This ended up working:
Code: [Select]
%obj.setVelocity(getword(%obj.getvelocity(),0) * 0.25 SPC getword(%obj.getvelocity(),1) * 0.25 SPC getWord(%obj.getVelocity(),2));Thanks for the help Ephi.