My maths is appalling when it comes to this sort of thing, so probably can’t be much help. But would getVectTo() be of any help here? Then you could use own.getVectTo(someObject) and it returns the distance to that object plus the local and world vectors to that object.
There’s probably a way to get the orientation to that object from the vector returned. Or you could apply a force to the object along the returned vector to get it to move towards the path point/other car without worrying about the angle maths.
Check the API for game objects for more on getting vectors and applying forces along them. Also the mathutils module might be worth looking over.
You need to define who the angle is calcualted from, and who it is calcualted to (the target) when calling the function. Some of it is probably redundant, but I like to be sure it works.
I use get vect to
and then align to vect/axis
to control the movenents of my AI characters, rather than trying to turn the charcter using the angle to target.
…But I find that understanding the angle to an object can help when choosing their behaviour.
For example, you can get the angle to the target to see if your character has line of sight in a sneaking type game. Or you can make other types of changes to behaviour based on angle.
That’s great. I also like the (commented out) function for drawing a line to the next waypoint. I do that too for testing. Helps you to know if it’s working OK.
Will the racers get punished for taking a short cut? Or will you have to go through the checkpoints to progress?