check a players direction
#1

how do i detect what direct the player is going in south southwest east west north etc?

like use angles?

If hes 180 north 360 south

is this the best way
Reply
#2

pawn Код:
new A; GetPlayerFacingAngle(playerid, A);
if(A < 45 || A > 315) print("Going north");
if(A > 225 && A < 315) print("Going west");
if(A > 135 && A < 225) print("Going south");
if(A > 45 && A < 135) print("Going east");
Might work, I don't know if 90 degrees is west or east ^^
Reply
#3

mhm saved me alot of typing thx lol just needed to clarify

edit. is there a possiblilty to detect what angle he is from you?
like south west from you
Reply
#4

360 - North
315 - North-West
270 - West
225 - South-West
180 - South
135 - South-East
090 - East
045 - North-East
0 - Same as 360, North
Reply
#5

so to detect what direction someone is from you

i do like..>?
Reply
#6

Use atan2(x, y);

For example:

pawn Код:
new Float:p1x, Float:p1y, Float:p1z;
GetPlayerPos(playerid1, p1x, p1y, p1z);
new Float:p2x, Float:p2y, Float:p2z;
GetPlayerPos(playerid2, p2x, p2y, p2z);
new Float:angle;
angle = atan2(p2x-p1x,p2y-p1y);
Reply
#7

Wut... I needed that *** ****** function a long time before (atan2) and you just... posted it?

Im gonna retire if everybody is pwning me this hard..
Reply
#8

lmao i dont even understand how to use it xD
Reply
#9

Quote:
Originally Posted by Kar
Посмотреть сообщение
lmao i dont even understand how to use it xD
angle is the direction you wanted.
Reply
#10

I need it in a command I made something to show his x y z coords but I need to to show the direction the player is from me like 0.36086(south-west)

will it do that?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)