Player face player
#2

to obtain the angle, the atan2 function is a good way:
Код:
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...
...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
Код:
SetPlayerFacePlayer(playerid, giveplayer)
i assume thats supposed to be a
Код:
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;
}
now i dont know which player gets set the returned angle, and which one needs to get added 180 lol
Reply


Messages In This Thread
Player face player - by Qur - 22.10.2012, 19:26
Re: Player face player - by Babul - 22.10.2012, 20:11
Re: Player face player - by Qur - 22.10.2012, 21:00
AW: Player face player - by Nero_3D - 22.10.2012, 21:36

Forum Jump:


Users browsing this thread: 1 Guest(s)