2026-03-31 물체 상호작용

This commit is contained in:
2026-03-31 18:08:26 +09:00
parent 71dfbf1af2
commit 902b1b76fb
141 changed files with 11063 additions and 343 deletions

View File

@@ -5,6 +5,7 @@
using UnityEditor.Experimental.GraphView;
using UnityEditorInternal;
using UnityEngine;
using UnityEngine.InputSystem;
using static Unity.Cinemachine.CinemachineSplineDolly;
using static UnityEngine.Rendering.DebugUI;
@@ -75,6 +76,10 @@ public enum PlayerRotationMode {CameraCoupled, CameraDecoupled}
public PlayerStat PlayerCharacterStat{ get; set; }
private Renderer[] _renderers;
//상호작용
public SphereCollider InteractionCollider;
public List<IInteractable> InteractionTargets = new List<IInteractable>();
//무기
//[SerializeField] private Weapon _weapon;
@@ -127,6 +132,9 @@ private void Update()
TickTimer();
//PlayerDebug();
Debug.Log($"InteractionTargetsCount : {InteractionTargets.Count}");
}
private void FixedUpdate()
@@ -395,6 +403,13 @@ private void JumpAction()
}
#endregion
#region
private void PointSitAction()
{
}
#endregion
#region
private void TickTimer()
{
@@ -516,6 +531,15 @@ public void AimToggleInput(InputState inputState)
}
}
public void InteractInput()
{
if (InteractionTargets.Count > 0)
{
IInteractable target = InteractionTargets[0];
target.InteractExec(this); // 실제 상호작용 실행
}
}
public void LookInput(Vector2 lookInput)
{
_lookInput = lookInput;
@@ -562,4 +586,27 @@ public void SetCursorLockState(bool isLocked)
Cursor.visible = !isLocked;
}
#endregion
private void OnTriggerEnter(Collider other)
{
// 상호작용 객체인지 확인
if (other.TryGetComponent<IInteractable>(out IInteractable interactable))
{
Debug.Log($"interactableName : {interactable}");
interactable.InteractOpen();
InteractionTargets.Add(interactable);
return;
}
}
private void OnTriggerExit(Collider other)
{
// 상호작용 객체인지 확인
if (other.TryGetComponent<IInteractable>(out IInteractable interactable))
{
interactable.InteractClose();
InteractionTargets.Remove(interactable);
}
}
}