22.10.2012, 20:11
to obtain the angle, the atan2 function is a good way:
...for the last line: you might swap player ids aswell, if 2 players are facing each other, then their angles are related to each other (180° offset, to be precise):
iam in angel pine (south west), youre in Dillimore (north east) - so i will face north east (45.0°), so you will face south west (225°), and 45°+180°=225° - calculate playerA's angle, playerB's angle=playerA's angle+180.0
edit: you forgot the semicolon after
i assume thats supposed to be a
now i dont know which player gets set the returned angle, and which one needs to get added 180 lol
Код:
new Angle=atan2(DiffX,DiffY);//or new Angle=atan2(X1-X2,Y1-Y2);//or new Angle=atan2(X2-X1,Y2-Y1);//in case your angles are rotated by 180 degrees, try this one instead of adding 180.0 later...
iam in angel pine (south west), youre in Dillimore (north east) - so i will face north east (45.0°), so you will face south west (225°), and 45°+180°=225° - calculate playerA's angle, playerB's angle=playerA's angle+180.0
edit: you forgot the semicolon after
Код:
SetPlayerFacePlayer(playerid, giveplayer)
Код:
stock SetPlayerFacePlayer(playerid, giveplayer){ new Float:PlayerX[2],Float:PlayerY[2],Float:PlayerZ[2]; GetPlayerPos(playerid,PlayerX[0],PlayerY[0],PlayerZ[0]); GetPlayerPos(giveplayer,PlayerX[1],PlayerY[1],PlayerZ[1]); new Angle=atan2(PlayerX[0]-PlayerX[1],PlayerY[0]-PlayerY[1]); return Angle; }