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()); } } }