Using a simple FSM for the enemy tank AI
Let's look at the actual code for our AI tanks. First, let's create a new class, called SimpleFSM
, which inherits from our FSM abstract class.
You can find the source code in the SimpleFSM.cs
file:
using UnityEngine; using System.Collections; public class SimpleFSM : FSM {     public enum FSMState {         None, Patrol, Chase, Attack, Dead,     }     //Current state that the NPC is reaching     public FSMState curState = FSMState.Patrol;     //Speed of the tank     private float curSpeed = 150.0f;     //Tank Rotation Speed     private float curRotSpeed = 2.0f;     //Bullet     public GameObject Bullet;     //Whether the NPC is destroyed or not     private...