Exemple #1
0
 public override void Update()
 {
     if (CanSeePlayer())
     {
         nextState = new Pursue(npc, agent, anim, player);
         stage     = EVENT.EXIT;
     }
     else if (Random.Range(0, 100) < 10)
     {
         nextState = new Patrol(npc, agent, anim, player);
         stage     = EVENT.EXIT;
     }
 }
Exemple #2
0
        public override void Update()
        {
            agent.SetDestination(player.position);

            // Must check if has path to ensure navmesh system has set path.
            if (agent.hasPath)
            {
                if (CanAttackPlayer())
                {
                    nextState = new Attack(npc, agent, anim, player);
                    stage     = EVENT.EXIT;
                }
                else if (!CanSeePlayer())
                {
                    nextState = new Patrol(npc, agent, anim, player);
                    stage     = EVENT.EXIT;
                }
            }
        }