Programming AI - Cars
Simple AI car routines using the NavMeshAgent, with Raycast to slow down the cars before possible collision of them. the car model is not mine, it belongs to my friend and classmate Carlos Vicente Pastor. therookies.co/u/CarlosPastor
This AI system is configured thanks to Unity's nav mesh.
The routes are randomised once the car is instantiated. Previously these routes are saved in a list through a script and the cars always have a reference of the possible routes.
the junction is the only one where the two lanes coexist.
Script for the vehicle
Script for a Checkpoint GameObject
We have two lanes and cars always drive on the right, so at every crossing they have to change the area where they can go and where they cannot go.
List of routes (Inspector Unity)
Component NavMeshAgent of the Car (Inspector)