public override void Update(EnemyAgent agent)
 {
     //check if target still in attack range if yes attack again after ending the attack animation
     agent.SetPlayerTarget();
     if (Vector3.Distance(agent.GetNavMeshAgent().destination, agent.transform.position) < agent.GetAttackRange())
     {
         if (agent.GetCurrentTimeBtwAttacks() <= 0)
         {
             agent.Attack();
         }
         else
         {
             agent.AdjustAttackTime();
         }
     }
     else
     {
         agent.SetState(FollowPlayerState.GetInstance());
     }
 }
    public override void Update(EnemyAgent agent)
    {
        //update position of the player
        agent.SetPlayerTarget();

        if (Vector3.Distance(agent.GetNavMeshAgent().destination, agent.transform.position) < agent.GetAttackRange() + 0.5f)
        {
            agent.SetState(AttackState.GetInstance());
        }
        if (Vector3.Distance(agent.GetNavMeshAgent().destination, agent.transform.position) > agent.GetFollowRange() + 0.5f)
        {
            if (agent.GetIsWaveEnemy() == false)
            {
                agent.SetState(PatrolState.GetInstance());
            }
            else
            {
                agent.SetState(ChargeBaseState.GetInstance());
            }
        }
    }
Beispiel #3
0
    public override void Update(EnemyAgent agent)
    {
        //check if player is in his way if yes follow player
        if (Vector3.Distance(agent.GetNavMeshAgent().destination, agent.transform.position) < agent.GetAttackRange() + 0.5f)
        {
            agent.SetState(AttackBaseState.GetInstance());
        }
        RaycastHit hit;

        if (Physics.SphereCast(agent.transform.position + new Vector3(0.5f, 0.5f, 0.5f), 0.5f, agent.transform.forward, out hit, agent.GetFollowRange()))
        {
            if (hit.collider.tag == "Player")
            {
                agent.SetState(FollowPlayerState.GetInstance());
            }
        }
    }