This process of building the AI for the enemy racers went at least 90% smoother than I thought it would have. Either I’m getting good at this programming thing or I just got lucky. Take a look at the video.
It’s rather simple, really. For each level, I create a map of “waypoints” for each of the enemy cars to follow. Once they hit one waypoint, they move onto the next. To make sure that they all don’t follow the same path, I used Math.random() to add to the x and y location of the waypoints so each car’s destination is different than the others. Maybe one lap a certain car will go into a turn perfectly but then the next lap he’ll go skidding into the dirt, who know? LOL!
Once I saw that the cars were able to navigate from point to point, I just basically copy and pasted the code from the player and whalla, they started to accelerate, brake, and turn. Magic, really.
To Do List:
– Obviously the AI isn’t completed. There’s that annoying depth issue where the cars just drive through eachother. To fix this, I’m going to code in a way to figure out what car is driving over who, and to adjust the depths of the two cars so it looks like one is driving on top of the other. This idea comes purely out of the Sega Genesis game I’m basing this whole project on, Combat Cars.
– Next, I have to get the AI to know when to use their own unique weapon. If there’s an open opportunity to take out an enemy vehicle, take it!
– After that I want to update/get new sounds for everything. I want to find the perfect sound for everything.
Well, that’s it. Whatcha think so far?