13.01.2011, 20:09
Hello guys. I have attached an object up to my head ( an arrow ), and i want, like the arrowhead to be directed toward a player. And i did like this:
But the arrowhead, doesn't coordinate me correct. I think I must use my Angle, because the attached_object's rY & rZ is changing when i move ...
pawn Код:
Float:GetRotationBetweenPoints(Float:x1, Float:y1, Float:x2, Float:y2)
return Float:(180-atan2(x1-x2,y1-y2));
pawn Код:
public OnPlayerUpdate(playerid)
{
new Float:x1,Float:x2,Float:y1,Float:y2,Float:z1,Float:z2;
GetPlayerPos(playerid,x1,y1,z1);
GetPlayerPos(Target[playerid],x2,y2,z2);
new Float:arrowhead = GetRotationBetweenPoints(x1, y1, x2, y2);
SetPlayerAttachedObject(playerid, 0, 1318, 1, 0.74976, 0.159999, 0.035997, arrowhead);
return 1;
}