26.03.2013, 11:40
hm... you first need to calculate the angle for player 1:
since you know the angle, you can use the sinus/cosinus and a radius (2 meters?) to calculate new x,y coordinates.
since those are only the offsets (relative to the player), you need to add player1's coordinates (x and y) to the results.
maybe you need to use (-angle,degrees) when NPCs/players/objects are facing the wrong direction - the formula should be (almost) ok..
pawn Код:
new Float:angle=atan2(player1x-player2x,player1y-player2y);
pawn Код:
new player1xoffset=2*sin(angle,degrees);
new player1yoffset=2*cos(angle,degrees);
maybe you need to use (-angle,degrees) when NPCs/players/objects are facing the wrong direction - the formula should be (almost) ok..