Maths: Calculating the angle required to face on checkpoint from a current location. - 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: Maths: Calculating the angle required to face on checkpoint from a current location. (
/showthread.php?tid=567154)
Maths: Calculating the angle required to face on checkpoint from a current location. -
Ash. - 11.03.2015
I'm not mathematically minded, so I'm struggling with this one.
I'm setting up a dynamic race system, in which checkpoints and races are created entirely in-game. I have a starting checkpoint (1st CP), which players can either drive to or be teleported to via in-game invites. Regardless of how they arrive, I need to put them in a race-grid formation.
I've got the formation working dynamically (use 1st CP as center, car to left, car to right, and then behind each of those "parent" cars).
However, now I need to get that entire formation rotated as a group, and facing the second checkpoint. This feel really complicated, and I'm not sure how to approach it.
I'd appreciate your help!
Ash
AW: Maths: Calculating the angle required to face on checkpoint from a current location. -
Nero_3D - 11.03.2015
I think that has been asked x times, it is "-atan2(X2 - X1, Y2 - Y1)" for the zAngle (X2, Y2 would be the second checkpoint and X1, Y1 the first - yeah there is a minus before atan2)