6 minutes
Bonus: Give the Other Cars a Driver
Nine lessons in, you have a road, a car that drifts, hostiles that damage you on contact, and a convoy. Drive it and something is still wrong, and it is the thing lesson three warned you about:
Nothing in this scene listens for that yet, so a blue car stands exactly where the pool put it.
Every other car on this road is parked. RoadSpawner picks a lane and a speed for each one, Pool hands that speed through on pool.acquired, and no system has ever read it. You have been weaving through a scrapyard.
A driver, not a mover
The obvious fix is to give the traffic a velocity and step it forward. Resist it, because this library already has three components that do exactly that — AISeek, AIAvoidance, AISteering — and every one of them is wrong for a car.
They move an agent by writing a position or a velocity. That works for something that walks. For a car it drives straight past stepCarDrive and takes the whole handling model with it: an AI that writes position can corner at any radius, stop dead from full speed, and never slide. You spent lesson two building grip, understeer and slip, and lesson six making a gravel patch cut grip to a tenth. A rival that ignores all three is not difficult, it is a cheat — and it reads as one the first time you try to out-brake it into a corner and it doesn't brake.
Continue reading
Unlock the Full Course
Every lesson, the runnable examples, and the finished build — yours to keep.