Hello,
I want to create a Ai race game.I created an AI to follow spline around track however I can not find a way that they can overtake them somehow. AI’s just blocks them each other. Could you suggest me a algorithm or smth to achieve overtake mechanism on AI.
This is rather complex since you’ve only provided so little information. A resonable solution is to have different lanes. Adding some more lanes to the track, that way the cars can change lanes to avoid collision and overtake other cars.
The algorithm is difficult again, since it depends on how the mechanic is supposed to be implemented. If you want a catchup mechanic for the game then you need to plan accordingly for that type of overtake.
But basically, if the car is closing in on another car, is faster and will be able to overtake, you can fire traces to verify if the terrain is passable. If it is then the car will prepare for an overtake. You can then have it slow down if the terrain starts to narrow down again, vice versa.
Many modern racing games have path tracing, and thus the algorithm is different from this.