From 34ab12a093d17e593244a135825db4f0c05d9ca2 Mon Sep 17 00:00:00 2001 From: dal4segno Date: Wed, 25 Feb 2026 21:13:06 +0900 Subject: [PATCH] =?UTF-8?q?=EC=B6=94=EA=B2=A9=20=ED=8F=AC=EA=B8=B0?= =?UTF-8?q?=EB=A1=9C=20=EC=9D=B8=ED=95=9C=20=EB=B3=B5=EA=B7=80=20=EC=8B=9C?= =?UTF-8?q?,=20=EB=B3=B5=EA=B7=80=ED=95=98=EB=8A=94=20=EB=8F=99=EC=95=88?= =?UTF-8?q?=20=EB=AC=B4=EC=A0=81=20=EC=83=81=ED=83=9C=20+=20=EC=B2=B4?= =?UTF-8?q?=EB=A0=A5=20=EC=A0=84=EC=B2=B4=20=ED=9A=8C=EB=B3=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Assets/Scripts/EnemyAIController.cs | 16 ++++++++++++++++ Assets/Scripts/EnemyUnit.cs | 27 +++++++++++++++++++++++++++ 2 files changed, 43 insertions(+) diff --git a/Assets/Scripts/EnemyAIController.cs b/Assets/Scripts/EnemyAIController.cs index 5ef8b68..6cb5853 100644 --- a/Assets/Scripts/EnemyAIController.cs +++ b/Assets/Scripts/EnemyAIController.cs @@ -916,6 +916,16 @@ namespace Northbound switch (state) { case EnemyAIState.Idle: + _agent.isStopped = true; + _agent.ResetPath(); + // 즉시 정지를 위해 velocity 초기화 + _agent.velocity = Vector3.zero; + // 복귀 완료 - 무적 해제 + if (_enemyUnit != null) + { + _enemyUnit.SetInvulnerable(false); + } + break; case EnemyAIState.Attack: _agent.isStopped = true; _agent.ResetPath(); @@ -940,6 +950,12 @@ namespace Northbound _agent.isStopped = false; _agent.speed = moveSpeed; _agent.SetDestination(_originPosition); + // 복귀 시작 - 체력 회복 및 무적 + if (_enemyUnit != null) + { + _enemyUnit.HealToFull(); + _enemyUnit.SetInvulnerable(true); + } break; case EnemyAIState.Dead: _agent.isStopped = true; diff --git a/Assets/Scripts/EnemyUnit.cs b/Assets/Scripts/EnemyUnit.cs index 9e20b62..749d3c2 100644 --- a/Assets/Scripts/EnemyUnit.cs +++ b/Assets/Scripts/EnemyUnit.cs @@ -36,6 +36,12 @@ namespace Northbound NetworkVariableWritePermission.Server ); + private NetworkVariable _isInvulnerable = new NetworkVariable( + false, + NetworkVariableReadPermission.Everyone, + NetworkVariableWritePermission.Server + ); + /// /// 사망 시 발생하는 이벤트 (매개변수: killerId) /// @@ -106,6 +112,9 @@ namespace Northbound if (!IsServer) return; if (_currentHealth.Value <= 0) return; + // 무적 상태면 데미지 무시 + if (_isInvulnerable.Value) return; + // 공격자의 팀 확인 if (NetworkManager.Singleton.SpawnManager.SpawnedObjects.TryGetValue(attackerId, out NetworkObject attackerObj)) { @@ -207,6 +216,24 @@ namespace Northbound #endregion + #region Invulnerability & Healing + + public bool IsInvulnerable() => _isInvulnerable.Value; + + public void SetInvulnerable(bool value) + { + if (!IsServer) return; + _isInvulnerable.Value = value; + } + + public void HealToFull() + { + if (!IsServer) return; + _currentHealth.Value = maxHealth; + } + + #endregion + private void OnDrawGizmosSelected() { #if UNITY_EDITOR