From what I have seen from how AI works in different games, some seem to follow a set path. So I will try to replicate that and create a path that my AI car will follow.
Here is a flowchart I made regarding the AI path. It will work by actively looking for a mark (game object) and target it. It will then drive towards the mark while turning towards it at the same time.
When the car reaches the mark it will then begin looking for the next mark and target it again. If there is no other mark the car will either stay locked on to one mark or loop back to the beginning mark.
I have used this system for the driving because I researched a few different methods and came to the conclusion that this method will for me will be the most reliable and effective.
I also used Miro to create this flowchart, where all our teams planning is.
Here is a simple function that allows the car to know a corner is coming. It works by simply accelerating towards its next mark and if the current turn angle is higher than a certain value, it will brake and begin slowing down.
if the car's current turn angle then drops below the set value, it will begin accelerating again.
The reason I have added this is so the car will be able to perform some turns by itself with no further code needed.