Path-following agents

As a next step, we need to create the character that will follow the path; in our example, this agent is just a cube object. Readers can replace the cube later with whatever 3D models they want. After we create the script, we add the VehicleFollowing script component to it, as shown in the following screenshot:

The properties of our VehicleFollowing script

The script takes a couple of parameters: first is the reference to the path object it needs to follow; then, we have the Speed and Mass properties, which we need in order to calculate the character's acceleration. The Is Looping flag, if checked, makes this entity follow ...

Get Unity Artificial Intelligence Programming - Fourth 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.