public void CheckDistance() { if (!target.GetComponent <Player>().isDead) { if (Vector3.Distance(target.position, transform.position) <= chaseRadius) { if (Vector3.Distance(target.position, transform.position) <= attackRadius) { //Attack state ChangeAnim(target.position - transform.position); stateMachine.ChangeState(GreyClaw_AttackState.Instance()); } else if (!isAttacking) { //Chase state stateMachine.ChangeState(GreyClaw_WalkingState.Instance()); } } else { //Idle State stateMachine.ChangeState(GreyClaw_IdleState.Instance()); } } else { //If player is dead ChangeAnim(Vector2.down); StopCoroutine("AttackCo"); } }
public static GreyClaw_AttackState Instance() { if (_instance == null) { _instance = new GreyClaw_AttackState(); } return(_instance); }