Enemy의 사망 애니메이션 로직
네트워크 상에서의 동작 확인 완료
This commit is contained in:
@@ -18,6 +18,9 @@ namespace Northbound
|
||||
[Tooltip("IsMoving bool parameter name in Animator")]
|
||||
public string isMovingParam = "IsMoving";
|
||||
|
||||
[Tooltip("Death trigger parameter name in Animator")]
|
||||
public string dieTriggerParam = "Die";
|
||||
|
||||
[Header("Settings")]
|
||||
[Tooltip("Auto-load animator controller from MonsterData")]
|
||||
public bool autoLoadFromMonsterData = true;
|
||||
@@ -27,6 +30,7 @@ namespace Northbound
|
||||
|
||||
private Animator _animator;
|
||||
private EnemyAIController _aiController;
|
||||
private EnemyUnit _enemyUnit;
|
||||
private NavMeshAgent _agent;
|
||||
|
||||
private NetworkVariable<float> _networkSpeed = new NetworkVariable<float>(
|
||||
@@ -47,9 +51,14 @@ namespace Northbound
|
||||
|
||||
_animator = GetComponent<Animator>();
|
||||
_aiController = GetComponent<EnemyAIController>();
|
||||
_enemyUnit = GetComponent<EnemyUnit>();
|
||||
_agent = GetComponent<NavMeshAgent>();
|
||||
|
||||
_aiController.OnAttackPerformed += HandleAttackPerformed;
|
||||
if (_enemyUnit != null)
|
||||
{
|
||||
_enemyUnit.OnDeath += HandleDeath;
|
||||
}
|
||||
|
||||
if (autoLoadFromMonsterData)
|
||||
{
|
||||
@@ -63,6 +72,10 @@ namespace Northbound
|
||||
{
|
||||
_aiController.OnAttackPerformed -= HandleAttackPerformed;
|
||||
}
|
||||
if (_enemyUnit != null)
|
||||
{
|
||||
_enemyUnit.OnDeath -= HandleDeath;
|
||||
}
|
||||
base.OnNetworkDespawn();
|
||||
}
|
||||
|
||||
@@ -74,6 +87,14 @@ namespace Northbound
|
||||
Debug.Log($"[MonsterAnimationController] Triggered attack animation for {target.name}", this);
|
||||
}
|
||||
|
||||
private void HandleDeath(ulong killerId)
|
||||
{
|
||||
if (!IsServer) return;
|
||||
TriggerDeathClientRpc();
|
||||
if (debugLogging)
|
||||
Debug.Log($"[MonsterAnimationController] Triggered death animation (killer: {killerId})", this);
|
||||
}
|
||||
|
||||
private void LoadAnimatorController()
|
||||
{
|
||||
var monsterDataComponent = GetComponent<MonsterDataComponent>();
|
||||
@@ -111,6 +132,14 @@ namespace Northbound
|
||||
|
||||
private void UpdateServerSide()
|
||||
{
|
||||
// 사망 상태면 이동 애니메이션 중지
|
||||
if (_aiController != null && _aiController.GetCurrentState() == EnemyAIState.Dead)
|
||||
{
|
||||
_networkSpeed.Value = 0f;
|
||||
_networkIsMoving.Value = false;
|
||||
return;
|
||||
}
|
||||
|
||||
if (_agent == null) return;
|
||||
|
||||
float currentSpeed = _agent.velocity.magnitude;
|
||||
@@ -137,6 +166,15 @@ namespace Northbound
|
||||
}
|
||||
}
|
||||
|
||||
[Rpc(SendTo.ClientsAndHost)]
|
||||
private void TriggerDeathClientRpc()
|
||||
{
|
||||
if (_animator != null)
|
||||
{
|
||||
_animator.SetTrigger(dieTriggerParam);
|
||||
}
|
||||
}
|
||||
|
||||
public void ResetAttackTrigger()
|
||||
{
|
||||
if (_animator != null)
|
||||
|
||||
Reference in New Issue
Block a user