In this example, the AI characters roam around the scene in a random direction. They have two senses: Sight and Touch. The Sight sense checks whether the enemy aspect is within a set visible range and distance. The Touch sense, instead, detects if the enemy aspect has collided with the box collider around the character. As we have seen previously, our player tank has the Enemy aspect. Consequently, these senses are triggered when they detect the player tank.
For now, let's look at the script we use to move the NPCs around. The following is the code in the Wander.cs file:
using UnityEngine; using System.Collections; public class Wander : MonoBehaviour { private Vector3 tarPos; private float movementSpeed = 5.0f; private float rotSpeed = 2.0f; private float minX, maxX, minZ, maxZ; // Use this for initialization void Start () { minX...