How it works...

The CarController class is the interface we use to connect drivers and cars, just as in real life. No matter whether the driver is a real player or an AI agent, the car behaves the same, and it depends on the driver to make the most of it. We've made all the variables public, because drivers need feedback from the car; players with UI and/or the gameplay can feel, even behavior from other drivers, and AI drivers need access to that same information as well.

Get Unity 2018 Artificial Intelligence Cookbook - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.