Recently I’ve been working on AI behaviour for the rival cars. The main focus has been convincing the non-player cars to avoid other cars rather than slamming into the back of them. As Oversteer Racing has a more realistic damage model than some top-down racers collisions tend to be more serious than in other games.
One downside of the non-player cars following a series of potential routes around the track means that they have no knowledge of where the edge of the track is. This makes things difficult when it comes to avoiding objects because it’s hard to work out which way to turn to avoid the object. For example, if a car has stopped on track then can the non-player cars pass to the left or to the right without leaving the track?
The work I’ve been doing uses a number of ray-casts from the cars to detect obstacles. Once an obstacle has been detected I use the route markers to determine which side of the track has more space. The car then steers towards that space.
This is still a work in progress as the cars are not consistently avoiding obstacles. To some degree I’m happy if the cars don’t always get this right because that seems more realistic but, at present, the non-player cars get this more wrong than right…