private void Rotate() { if (player.SetAlive() != true) { return; } Vector2 mouseWorldPosition = Camera.main.ScreenToWorldPoint(Input.mousePosition); var direction = mouseWorldPosition - (Vector2)transform.position; transform.up = -direction; }
private void UpdateState() { var distance = Vector2.Distance(transform.position, player.transform.position); switch (activeState) { case ZombieStates.Stand: if (distance <= followDistance) { if (CheckPlayer() <= angleVision) { ChangeStateToMove(distance); } } anim.SetFloat(Speed, path.velocity.magnitude); break; case ZombieStates.Move: if (distance <= attackDistance && player.SetAlive()) { ChangeState(ZombieStates.Attack); } Rotate(); if (distance >= followDistance) { ChangeState(ZombieStates.Stand); } anim.SetFloat(Speed, path.velocity.magnitude); break; case ZombieStates.Attack: if (distance > attackDistance || player.SetAlive() == false) { ChangeState(ZombieStates.Move); } Rotate(); anim.SetFloat(Speed, path.velocity.magnitude); break; default: throw new ArgumentOutOfRangeException(); } }