void MoveToTarget(Vector3 direction) { if (targetDistance > 70f && state != anglerfishState.biting) { rb.velocity = direction * speed; } else if (targetDistance <= 50f && state == anglerfishState.chasing) { rb.velocity = direction * speed / 5; state = anglerfishState.biting; Damage(); } }
private void Update() { ChangeMusic(); targetDistance = Vector3.Distance(target.position, transform.position); Vector3 direction = target.position - transform.position; direction.Normalize(); movement = direction; switch (state) { case anglerfishState.chasing: LookAtTarget(); print("chasing"); break; case anglerfishState.biting: print("biting"); //Application.Quit(); state = anglerfishState.chasing; break; } }