How can I get the x y z pos of the BACK/FRONT of something? - 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: How can I get the x y z pos of the BACK/FRONT of something? (
/showthread.php?tid=662496)
How can I get the x y z pos of the BACK/FRONT of something? -
aKnoxx - 03.01.2019
Say I want to make a cmd to put an object IN FRONT of a player. Or spawn a vehicle IN FRONT of a player. How do I do that?
When I do it like this:
GetPlayerPos(playerid, x, y, z);
And then do
x +2, y, z
It spawns it +2 x. And then when I do +3 y, it spawns it +3 y, ect. I can't figure out how to make it spawn in front of me. I'd assume it has something to do with math and your facing angle but I can't figure out how to do it. How can I do something like that?
Re: How can I get the x y z pos of the BACK/FRONT of something? -
beckzy - 03.01.2019
Get the X and Y 2 units in front of a player:
Код:
new Float:x, Float:y, Float:z, Float:a;
GetPlayerPos(playerid, x, y, z);
GetPlayerFacingAngle(playerid, a);
x += floatsin(-a, degrees) * 2.0;
y += floatcos(-a, degrees) * 2.0;
Get the X and Y 2 units behind a player:
Код:
new Float:x, Float:y, Float:z, Float:a;
GetPlayerPos(playerid, x, y, z);
GetPlayerFacingAngle(playerid, a);
a = a < 180.0 ? a + 180.0 : a - 180.0;
x += floatsin(-a, degrees) * 2.0;
y += floatcos(-a, degrees) * 2.0;