- #1
VX967
- 3
- 0
Hey there, I'm new to these forums. I'm currently trying to steer an AI kart for a racing game I'm making in Blender. I'm not sure if anyone on these forums has experience with programming games or AI, but here it goes.
Basically, there is a steering actuator that returns a steering vector (x,y,z). This traces the path that the kart should go around the track, and updates in real-time.
I also have the kart's local orientation, also in the form of a vector (x,y,z).
What I'm trying to do is somehow relate those vectors into an equation of some sort and come out with an angle.
So if the steering vector points to the right [relative to the kart's local orientation vector], it will come out with a positive angle [relative to the kart's front] and will turn the wheels positively to turn right. If the steering vector points to the left of the kart's local orientation, it will return a negative angle and steer the kart to the left.
[Note that I'm only looking for a clear distinction of left or right by using positive or negative. The wheels will always turn by a set amount, so the extremities of the values are ignored.]
If anyone is familiar with Blender or Python, here's the code I was suggested:
However, it always returns a positive value. I hope this question isn't too confusing. I can draw a diagram if necessary.
EDIT: I created a visual representation.
Basically, there is a steering actuator that returns a steering vector (x,y,z). This traces the path that the kart should go around the track, and updates in real-time.
I also have the kart's local orientation, also in the form of a vector (x,y,z).
What I'm trying to do is somehow relate those vectors into an equation of some sort and come out with an angle.
So if the steering vector points to the right [relative to the kart's local orientation vector], it will come out with a positive angle [relative to the kart's front] and will turn the wheels positively to turn right. If the steering vector points to the left of the kart's local orientation, it will return a negative angle and steer the kart to the left.
[Note that I'm only looking for a clear distinction of left or right by using positive or negative. The wheels will always turn by a set amount, so the extremities of the values are ignored.]
If anyone is familiar with Blender or Python, here's the code I was suggested:
Code:
angle = obj.localOrientation[1].angle(steervector)
However, it always returns a positive value. I hope this question isn't too confusing. I can draw a diagram if necessary.
EDIT: I created a visual representation.
Attachments
Last edited: