diff --git a/Assets/Scripts/BuildingPlacement.cs b/Assets/Scripts/BuildingPlacement.cs index 60b839b..ae435a5 100644 --- a/Assets/Scripts/BuildingPlacement.cs +++ b/Assets/Scripts/BuildingPlacement.cs @@ -61,6 +61,12 @@ namespace Northbound TryInitializeInput(); } + private void Start() + { + // Start에서 다시 한번 확인 (이벤트 타이밍 문제 해결) + TryInitializeInput(); + } + private void TryInitializeInput() { if (_isInitialized) return; // 이미 초기화됨 diff --git a/Assets/Scripts/NetworkPlayerController.cs b/Assets/Scripts/NetworkPlayerController.cs index c1a1c6c..d282c04 100644 --- a/Assets/Scripts/NetworkPlayerController.cs +++ b/Assets/Scripts/NetworkPlayerController.cs @@ -161,6 +161,28 @@ public class NetworkPlayerController : NetworkBehaviour, ITeamMember, IDamageabl _ownerPlayerId.Value = ownerPlayerId; } + /// + /// 입력 강제 복구 (입력이 멈췄을 때 호출) + /// + public void ForceRecoverInput() + { + if (!IsLocalPlayer) return; + + // InputActions가 없으면 초기화 시도 + if (_inputActions == null) + { + TryInitializeLocalPlayer(); + return; + } + + // InputActions가 있지만 비활성화되어 있으면 활성화 + if (!_inputActions.Player.enabled && _currentHealth.Value > 0) + { + _inputActions.Enable(); + Debug.Log("[NetworkPlayerController] 입력 강제 복구 완료"); + } + } + public override void OnNetworkDespawn() { _currentHealth.OnValueChanged -= OnHealthChanged; @@ -182,6 +204,10 @@ public class NetworkPlayerController : NetworkBehaviour, ITeamMember, IDamageabl // 서버 측 이동 입력 저장 private Vector2 _serverMoveInput; + // 입력 복구 체크 + private float _inputRecoveryCheckInterval = 1f; // 1초마다 체크 + private float _inputRecoveryCheckTimer; + void Update() { // 서버에서 체력 자연 회복 처리 @@ -193,8 +219,24 @@ public class NetworkPlayerController : NetworkBehaviour, ITeamMember, IDamageabl // 로컬 플레이어만 입력 처리 if (!IsLocalPlayer) return; - // 입력 시스템이 초기화되지 않았으면 스킵 - if (_inputActions == null) return; + // 입력 시스템이 초기화되지 않았으면 초기화 시도 + if (_inputActions == null) + { + TryInitializeLocalPlayer(); + return; + } + + // 주기적으로 입력 상태 확인 및 자동 복구 (살아있는데 입력이 비활성화된 경우) + _inputRecoveryCheckTimer += Time.deltaTime; + if (_inputRecoveryCheckTimer >= _inputRecoveryCheckInterval) + { + _inputRecoveryCheckTimer = 0f; + if (_currentHealth.Value > 0 && !_inputActions.Player.enabled) + { + Debug.LogWarning("[NetworkPlayerController] 입력이 비활성화되어 있음 - 자동 복구"); + _inputActions.Enable(); + } + } // 죽었으면 이동 불가 if (_currentHealth.Value <= 0) return; diff --git a/Assets/Scripts/PlayerActionSystem.cs b/Assets/Scripts/PlayerActionSystem.cs index 34ed06c..febeabd 100644 --- a/Assets/Scripts/PlayerActionSystem.cs +++ b/Assets/Scripts/PlayerActionSystem.cs @@ -56,6 +56,12 @@ namespace Northbound TryInitializeInput(); } + private void Start() + { + // Start에서 다시 한번 확인 (이벤트 타이밍 문제 해결) + TryInitializeInput(); + } + private void OnOwnerPlayerIdChanged(ulong newOwnerId) { TryInitializeInput(); diff --git a/Assets/Scripts/PlayerInteraction.cs b/Assets/Scripts/PlayerInteraction.cs index fc11d98..6824440 100644 --- a/Assets/Scripts/PlayerInteraction.cs +++ b/Assets/Scripts/PlayerInteraction.cs @@ -84,6 +84,12 @@ namespace Northbound TryInitializeInput(); } + private void Start() + { + // Start에서 다시 한번 확인 (이벤트 타이밍 문제 해결) + TryInitializeInput(); + } + private void OnOwnerPlayerIdChanged(ulong newOwnerId) { TryInitializeInput();