In "Player Vars.txt", there are two variables that you need to use:
Heading, // Direction of forward axis : 0 = world y direction
Direction, // Car's motion if Speed > 0 : 0 = world y direction
First, convert them to the appropriate format.
- They might be in a byte range instead of degrees [0-255]. Simply multiply them by 360 and divide them by 255.
(x * 360 / 255)
- If both of them aren't clockwise or anti-clockwise, convert one to other's.
(360 - x)
- Both of them start from the same axis (+y), so you dont need to adjust it in this case.
Final format: Both of them
(C +y) or
(AC +y), range [0, 360].
Then all you need to do is:
- Calculate the difference between them to get the angle.
Angle = abs(Heading - Direction) [0 - 360]
- If it is greater than 180, substract from 360.
Angle = 360 - Angle [0 - 180]
(In case of something like Heading is 350 and Direction is 10, Angle should be 20, not 340)
Keep us updated if it works or not.