SA-MP Forums Archive
SetVehicleVelocity(Help Please) - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: SetVehicleVelocity(Help Please) (/showthread.php?tid=96638)



SetVehicleVelocity(Help Please) - user226 - 09.09.2009

thanks all


Re: SetVehicleVelocity(Help Please) - d0 - 09.09.2009

this will help:
1.5*x
1.5*y
1.5*z
or 2.0

+y = north
-y = south
+x = east
-x = west
+z = up
-z = down


Re: SetVehicleVelocity(Help Please) - Angelus~ - 09.09.2009

Quote:
Originally Posted by Doerfler
this will help:
1.5*x
1.5*y
1.5*z
or 2.0

+y = north
-y = south
+x = east
-x = west
+z = up
-z = down
Basically what he said, if you add or subtract the values it only goes the certain direction, the only way to increase speed in any direction is to multiply X and Y by the same value so the ratio between both X and Y stays the same


Re: SetVehicleVelocity(Help Please) - user226 - 09.09.2009

hm...
if(Angle,90.0 <= 0) SetVehicleVeloCity......
yes or no?


Re: SetVehicleVelocity(Help Please) - Angelus~ - 09.09.2009

Quote:
Originally Posted by kruts
hm...
if(Angle,90.0 <= 0) SetVehicleVeloCity......
yes or no?
No the facing angle doesn't matter with SetVehicleVelocity or SetPlayerVelocity.
the function sets the velocity in a specific direction, X, Y, and Z
Notice on your minimap there's a N on the top? thats north
so if you input SetVehicleVelocity(vehicleid, 0, 1, 0) your vehicle would slowly go north
if you input SetVehicleVelocity(vehicleid, 0, 0, 2) your vehicle would jump up
if you input SetVehicleVelocity(vehicleid, 0, -2, ) your vehicle would go south because the opposite of north is south
now if you input SetVehicleVelocity(vehicleid, 1, 1, 0) your vehicle will speed up North and East by the velocity of 1, and the resulting vector or path would be the the middle or North East
This isn't like SetPlayerPos
this is just Speed with given directions
if you setup a command that get the vehicle's velocity, and then multiply it by a certain number, then you can speed up in any direction you are facing since the ratio is the same (1/2 = 2/4)


Re: SetVehicleVelocity(Help Please) - Daren_Jacobson - 10.09.2009

let's see if i still remember how to do this

pawn Код:
new Float:x, Float:y, Float:z, Float:angle, carid;
carid = GetPlayerVehicleID(playerid);
GetVehicleVelocity(carid, x, y, z);
GetPlayerZAngle(carid, angle);
x = 0.2 * floatcos(angle + 90.0, degrees) + x;
y = 0.2 * floatsin(angle + 90.0, degrees) + y;
SetVehicleVelocity(carid, x, y, z);
if you find it is always going at a certain angle to the way you are facing, just change the + 90.0 to some dif numbers till you get it right.