EnemySniper가 플레이어가 가까이 가면 상태머신이 이상해지면서 공격후 제자리에서 일어나는 버그를 발견하였습니다.
IsInChaseRange인데 IsInAttackRange가 false 일 경우의 예외를 추가해서 문제를 해결protected bool IsInChaseRange() { // if (stateMachine.Target.IsDead) { return false; } Vector3 enemyPosition = stateMachine.Enemy.transform.position + new Vector3(0, 1f, 0); float ChasingRange = 1f; if (RaycastToTag(enemyPosition, stateMachine.Enemy.transform.forward, ChasingRange, "Enemy")) return false; float playerDistanceSqr = (stateMachine.Target.transform.position - stateMachine.Enemy.transform.position).sqrMagnitude; return playerDistanceSqr <= stateMachine.Enemy.Data.PlayerChasingRange * stateMachine.Enemy.Data.PlayerChasingRange; } protected bool IsInAttackRange() { // if (stateMachine.Target.IsDead) { return false; } Vector3 enemyPosition = stateMachine.Enemy.transform.position + new Vector3(0, 1f, 0); float attackRange = stateMachine.Enemy.Data.AttackRange; if (RaycastToTag(enemyPosition, stateMachine.Enemy.transform.forward, attackRange, "Player")) { float playerDistanceSqr = (stateMachine.Target.transform.position - stateMachine.Enemy.transform.position).sqrMagnitude; return playerDistanceSqr <= stateMachine.Enemy.Data.AttackRange * stateMachine.Enemy.Data.AttackRange; } return false; }