How can I get the x y z pos of the BACK/FRONT of something?
#1

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?
Reply
#2

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;
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)