I’m trying to make a vehicle AI for my racing game. This isn’t an open world game. So, the roads in the game are fixed, but I do have some shortcuts. I have some worries in my mind about the AI I’m going to make. So, I wanna ask some things before I start coding.
An example road is right down below. Here’s the things I’m thinking of:
Should I use waypoints (just blue and green dots, no splines) and navigation mesh to find paths between waypoints?
Should I use splines and maybe mixture it with navigation mesh to find paths? If so, how can I make the crossroad in the image? A spline point can’t have more than 1 spline point to connect. (The green dots. Only one of them can be connected to the one before).
Also, there’s one more thing I should consider. Let’s say I coded the AI and it can choose which path it will go on at crossroads, and let’s say the AI’s chose the one on the bottom. (2nd path). If a real player forces AI to go on the 1st path by crashing or pushing, how will AI know that it can’t go on the 2nd path, so, it should go on the 1st path?
This forum is more for “I did this in my script and it surprised me because instead of X happening, Y happened.”
My suggestion above is that ALL of the approaches you list could work.
Apart and aside from the branching problem, just trying to get a car AI to realistically follow an arbitrary linear loop track is no simple feat.
It’s not even really that easy if you do all the hard work and pre-code hints into the level that the AI can use, such as target velocities at each point and turn initiation markers, but even then you need to account for other AI cars as well as the player car, because what the AI wants to do might send him right into the player’s future position. At some point every unhandled condition is going to look weird.
Now if you want a computer AI to analyze an arbitrarily linear loop of waypoints on an arbitrarily-shaped track and then to perform well against a human computer, that falls DEEP into the “hard problem” category, hard problem as in “use an AI neural net and give it a huge amount of training on how to solve the problem,” hard.
My experience is that ALL current racing games use some flavor of the former approach, a fully-authored AI environment for each level, with tons and tons of noodling and adjustment (basically thousands of hours of playtesting and tweaking parameters) to get a reasonable result. I suggest you start down that path and see how it goes.
ALSO: there’s often fudge moves the AI cars can do just to make them not be ultra-easy for a human to nudge off the track. It’s extremely common for AI cars to have WAY better instantaneous skid recovery to get back on track, otherwise you just clip them in the corner and you never have to think about them.
You might want to see if there are any good postmortem videos out for things like Mario Kart or Ridge Racer or any of the popular racing games out there. Someone has probably penned some interesting discussions you could benefit from.