Beispiel #1
0
 // Start is called before the first frame update
 void Awake()
 {
     navMeshAgent = GetComponent <UnityEngine.AI.NavMeshAgent>();
     normalState  = new NormalState(this);
     hungryState  = new HungryState(this);
     sleepState   = new SleepState(this);
     runAwayState = new RunAwayState(this);
 }
    // simple state machine
    protected override void Init()
    {
        target = new Cat();

        HungryState hungry = new HungryState();
        AddState(hungry);

        FullState full = new FullState();
        AddState(full);

        defaultState = hungry;

        AddTransition(new FiniteStateTransition("give_food", "HungryState", "FullState"));
        AddTransition(new FiniteStateTransition("run", "FullState", "HungryState"));
    }