Vehicle coordinates and vehicle angle - 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)
+--- Thread: Vehicle coordinates and vehicle angle (
/showthread.php?tid=604721)
Vehicle coordinates and vehicle angle -
ScIrUsna - 09.04.2016
Hi,
I have Float:X and i'am adding +5.0, but this only works when vehicle face to north if i face to another adding x coordinate +5 give my front that mean i think i have add +5 to Y not to X. I need to make effect only for x axis how calculate vehicle angle and to what coordinate x or y i have to add my value
Re: Vehicle coordinates and vehicle angle -
Vanter - 09.04.2016
PHP код:
new currentveh = GetPlayerVehicleID(playerid);
new Float:vehx, Float:vehy, Float:vehz Float:z_rot;
GetVehiclePos(currentveh, vehx, vehy, vehz);
GetVehicleZAngle(currentveh, z_rot);
next time
please use
******
Re: Vehicle coordinates and vehicle angle -
ScIrUsna - 09.04.2016
That is not what i need
Код:
new Float:XXX, Float:YY, Float:ZZZ;
GetVehiclePos( GetPlayerVehicleID(playerid), XXX, YY, ZZZ );
CreateDynamicObject( 1215, XXX+0.5,YY,ZZZ, 0.0, 0.0, 0.0 );
That green is vehicle they are same, As you see if i add +0.5 when vehicle angle to north everything is good, but if i face to east in the same direction adds value ,although the machine is already in the other direction, as a result this give my along machine position i need that new position when i add +0.5 will be in left or right side that mean i think i need to change y coordinate, but how to calculate it nice
Re: Vehicle coordinates and vehicle angle -
Virtual1ty - 09.04.2016
By using GetVehicleZAngle and trig:
pawn Код:
new vehicleid = GetPlayerVehicleID(playerid);
new Float:vX, Float:vY, Float:vZ, Float:vAngle;
GetVehiclePos(vehicleid, vX, vY, vZ);
GetVehicleZAngle(vehicleid, vAngle);
vX += 0.5 * floatsin(-vAngle, degrees);
vY += 0.5 * floatcos(-vAngle, degrees);
CreateDynamicObject(1215, vX, vY, vZ, 0.0, 0.0, 0.0);