public static AttackBaseState GetInstance() { if (_instance == null) { _instance = new AttackBaseState(); } return(_instance); }
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()); } } }