입력 못받는 버그 추가 수정 및 입력 로직 강제 복구 로직 추가
This commit is contained in:
@@ -61,6 +61,12 @@ namespace Northbound
|
|||||||
TryInitializeInput();
|
TryInitializeInput();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void Start()
|
||||||
|
{
|
||||||
|
// Start에서 다시 한번 확인 (이벤트 타이밍 문제 해결)
|
||||||
|
TryInitializeInput();
|
||||||
|
}
|
||||||
|
|
||||||
private void TryInitializeInput()
|
private void TryInitializeInput()
|
||||||
{
|
{
|
||||||
if (_isInitialized) return; // 이미 초기화됨
|
if (_isInitialized) return; // 이미 초기화됨
|
||||||
|
|||||||
@@ -161,6 +161,28 @@ public class NetworkPlayerController : NetworkBehaviour, ITeamMember, IDamageabl
|
|||||||
_ownerPlayerId.Value = ownerPlayerId;
|
_ownerPlayerId.Value = ownerPlayerId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 입력 강제 복구 (입력이 멈췄을 때 호출)
|
||||||
|
/// </summary>
|
||||||
|
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()
|
public override void OnNetworkDespawn()
|
||||||
{
|
{
|
||||||
_currentHealth.OnValueChanged -= OnHealthChanged;
|
_currentHealth.OnValueChanged -= OnHealthChanged;
|
||||||
@@ -182,6 +204,10 @@ public class NetworkPlayerController : NetworkBehaviour, ITeamMember, IDamageabl
|
|||||||
// 서버 측 이동 입력 저장
|
// 서버 측 이동 입력 저장
|
||||||
private Vector2 _serverMoveInput;
|
private Vector2 _serverMoveInput;
|
||||||
|
|
||||||
|
// 입력 복구 체크
|
||||||
|
private float _inputRecoveryCheckInterval = 1f; // 1초마다 체크
|
||||||
|
private float _inputRecoveryCheckTimer;
|
||||||
|
|
||||||
void Update()
|
void Update()
|
||||||
{
|
{
|
||||||
// 서버에서 체력 자연 회복 처리
|
// 서버에서 체력 자연 회복 처리
|
||||||
@@ -193,8 +219,24 @@ public class NetworkPlayerController : NetworkBehaviour, ITeamMember, IDamageabl
|
|||||||
// 로컬 플레이어만 입력 처리
|
// 로컬 플레이어만 입력 처리
|
||||||
if (!IsLocalPlayer) return;
|
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;
|
if (_currentHealth.Value <= 0) return;
|
||||||
|
|||||||
@@ -56,6 +56,12 @@ namespace Northbound
|
|||||||
TryInitializeInput();
|
TryInitializeInput();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void Start()
|
||||||
|
{
|
||||||
|
// Start에서 다시 한번 확인 (이벤트 타이밍 문제 해결)
|
||||||
|
TryInitializeInput();
|
||||||
|
}
|
||||||
|
|
||||||
private void OnOwnerPlayerIdChanged(ulong newOwnerId)
|
private void OnOwnerPlayerIdChanged(ulong newOwnerId)
|
||||||
{
|
{
|
||||||
TryInitializeInput();
|
TryInitializeInput();
|
||||||
|
|||||||
@@ -84,6 +84,12 @@ namespace Northbound
|
|||||||
TryInitializeInput();
|
TryInitializeInput();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void Start()
|
||||||
|
{
|
||||||
|
// Start에서 다시 한번 확인 (이벤트 타이밍 문제 해결)
|
||||||
|
TryInitializeInput();
|
||||||
|
}
|
||||||
|
|
||||||
private void OnOwnerPlayerIdChanged(ulong newOwnerId)
|
private void OnOwnerPlayerIdChanged(ulong newOwnerId)
|
||||||
{
|
{
|
||||||
TryInitializeInput();
|
TryInitializeInput();
|
||||||
|
|||||||
Reference in New Issue
Block a user