-
Notifications
You must be signed in to change notification settings - Fork 4
Technical: Driver AI
AI should be implemented as a component that can be added to the karts (in this Repo, inheriting from KartInput). This "separation of concerns" means features only used by the AI like collision sensors, navigation agents and taxing vector math can be instanced, enabled and disabled separately.
As a developer, your priorities for this system should be, in order:
- The AI can successfully drive the kart around the track;
- The AI can drive the kart around while obstacles are thrown at them;
- The AI can compete and race its way to 1st place, if given reasonable advantages.
todo
Obstacles here have a particular meaning: anything that's dynamic, not static. This may include other racers, or items, or moving sections of the track like drawbridges, gates and moving platforms.
This doesn't require obstacle avoidance, per se; as a player, you don't want CPU controlled opponents that can perfectly dodge all your tools. The goal here is to make the AI able to recover itself after such events and get back to racing. It can't get stuck after running over an e.g. oil spill, or not be able to drive on a moving platform as it's not in the navigation mesh.
This will usually require some sort of state machine to determine if the AI is on track or stranded off-track, if it's driving on reverse or not. Worst case scenario, if the kart gets stuck for too long, you can warp it back to the track.
Avoidance is still desirable, however. AI drivers should avoid direct contact with other karts as that can disrupt steering for both. Steering away from traps and track gimmicks also makes the AI seem more responsive, helping with the game's immersion and making it more fun.
The simplest approach to racing AI is to define a "racing line" as a Path3D, and have AI drivers follow that path. Worst case scenario, drivers can be programmed to follow the path exactly, as if "on-rails", which could be acceptable for a 90's shovelware game but that's it. We can do better and use these paths for guiding steering, which still lets AI react to being thrown off its path.

write about navigation and pathfinding. write about driver and obstacle avoidance. write about rubberbanding.
https://youtu.be/SKXqWcaoTGE?si=8yV8Q9nSEjdV45vU&t=1209