상호작용이 불가능한 상태에서도 모달 UI가 나타나도록 변경

This commit is contained in:
2026-02-12 14:49:18 +09:00
parent 2bb4797ec5
commit b32cc925e3
5 changed files with 124 additions and 14 deletions

View File

@@ -34,6 +34,7 @@ namespace Northbound
private PlayerInputActions _inputActions;
private IInteractable _currentInteractable;
private IInteractable _unavailableInteractable;
private Camera _mainCamera;
private Animator _animator;
private EquipmentSocket _equipmentSocket;
@@ -45,6 +46,7 @@ namespace Northbound
public bool IsInteracting => _isInteracting;
public float WorkPower => workPower;
public IInteractable CurrentUnavailableInteractable => _unavailableInteractable;
public override void OnNetworkSpawn()
{
@@ -92,30 +94,42 @@ namespace Northbound
{
Vector3 origin = rayOrigin.position;
Vector3 direction = useForwardDirection ? transform.forward : _mainCamera.transform.forward;
Ray ray = new Ray(origin, direction);
if (showDebugRay)
{
Debug.DrawRay(ray.origin, ray.direction * interactionRange,
Debug.DrawRay(ray.origin, ray.direction * interactionRange,
_currentInteractable != null ? Color.green : Color.yellow);
}
if (Physics.Raycast(ray, out RaycastHit hit, interactionRange, interactableLayer))
{
IInteractable interactable = hit.collider.GetComponent<IInteractable>();
if (interactable == null)
interactable = hit.collider.GetComponentInParent<IInteractable>();
if (interactable != null && interactable.CanInteract(OwnerClientId))
if (interactable != null)
{
_currentInteractable = interactable;
return;
if (interactable.CanInteract(OwnerClientId))
{
_currentInteractable = interactable;
_unavailableInteractable = null;
return;
}
else
{
// CanInteract가 false인 경우 추적
_currentInteractable = null;
_unavailableInteractable = interactable;
return;
}
}
}
_currentInteractable = null;
_unavailableInteractable = null;
}
private void OnInteract(InputAction.CallbackContext context)