Velocity change problem
#1

I'm now trying to change vehicle velocity (for example from X=1.5 Y=-2 Z=0 to X=-1.5 Y=2 Z=0), but it doesn't work properly... Sometimes it works fine (if the velocity X and Y is higher than 0), but on few directions the velocity doesn't change or my vehicle 'flies' to diffrent ways (not behind me or ahead, but on the left or right). The code I'm using:

Code:
new Float:X, Float:Y, Float:Z;
GetVehicleVelocity(GetPlayerVehicleID(playerid),X,Y,Z);

if(X >= 0)
{
      X = -X;
}
if(Y >= 0)
{
      Y = -Y;
}
if(Z >= 0)
{
      Z = -Z;
}

SetVehicleVelocity(GetPlayerVehicleID(playerid),X,Y,Z);
I hope someone will find what's wrong here and help me
Reply
#2

why do you check if those values are greater than zero?
Reply
#3

agreed. if you check for positive velocity, then only when driving north or east will trigger that axis. simply dont check for any speed, try:
Code:
new Float:X, Float:Y, Float:Z;
GetVehicleVelocity(GetPlayerVehicleID(playerid),X,Y,Z);
X=-X;
Y=-Y;
Z=-Z;
SetVehicleVelocity(GetPlayerVehicleID(playerid),X,Y,Z);
Reply
#4

Oh, thank you Babul Enjoy your rep
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)