An Arrow to a Point - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: An Arrow to a Point (
/showthread.php?tid=314213)
An Arrow to a Point -
blackybecks - 29.01.2012
Hello guys,
I search for a script where i can let point an Arrow to a Point like this:
[ame]http://www.youtube.com/watch?v=AOxeFu38_5g&feature=player_embedded[/ame]
Re: An Arrow to a Point -
Babul - 29.01.2012
have a look at the atan2 function:
pawn Code:
new Float:Angle=-(90+(atan2(YA-YB,XA-XB)));
all you need is the offset between both locations (x and y axis, the height can be ignored i guess). to get the offset, simply subtract x2 from x1, and y2 from y1. then apply the atan2 function with those 2 offsets. it will return an euler angle. idk if its a good advice to simply remove the -90 degrees in that formula, but feel free to experiment with it. this version takes the z-axis flipping relation betwen a player and objects (left/right handed) into account, thats why iam sure it could work for you
AW: An Arrow to a Point -
blackybecks - 29.01.2012
I test it but thank you