Setting up the tank

The example project also includes a prefab for the tank, which is simply called (you guessed it) Tank, inside the Prefabs folder.

The tank itself is a simple agent with one goal: reach the end of the maze. As mentioned earlier, the player has to help the tank out along the way by activating its abilities to keep it safe from oncoming fire from the towers.

By now, you should be fairly familiar with the components you'll encounter along the way, except for the Tank.cs component attached to the prefab. Let's take a look at the code to figure out what's going on behind the scenes:

using UnityEngine; using System.Collections; public class Tank : MonoBehaviour { [SerializeField] private Transform goal; private NavMeshAgent agent; ...

Get Unity 2017 Game AI Programming - Third 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.