Maths: Calculating the angle required to face on checkpoint from a current location.
#1

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
Reply
#2

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)
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)