2026-04-03 상호작용 버그 수정

This commit is contained in:
2026-04-03 11:34:25 +09:00
parent 7e19e4f248
commit 78e0f1a5b6
5 changed files with 47 additions and 17 deletions

Binary file not shown.

View File

@@ -26,6 +26,8 @@ public class GameManager : MonoBehaviour
public float ItemBounceFrequency = 2f; // 오르내리는 속도
[Header("Global Refer")]
public GameObject StaticObjectsField;
public GameObject DynamicObjectsField;
public HighlightProfile InteractionHighlightProfile;
private void Awake()

View File

@@ -353,6 +353,7 @@ public void SpawnItemToWorld(ItemInstance dropItem)
// 빈 게임오브젝트를 생성하고 WorldItem 컴포넌트를 붙임
GameObject dropObj = new GameObject($"{dropItem.Data.ItemName}_Dropped");
dropObj.transform.SetParent(GameManager.Instance.DynamicObjectsField.transform);
dropObj.transform.position = dropPosition;
WorldItem worldItem = dropObj.AddComponent<WorldItem>();
@@ -371,4 +372,17 @@ public void DropItemFromSlot(int slotIndex)
UpdateUI();
}
public void ItemUse(int slotIndex)
{
GameManager.Instance.ItemEffect.ItemUse(Items[slotIndex]);
Items[slotIndex].CurrentStack -= 1;
if (Items[slotIndex].CurrentStack <= 0)
{
Slots[slotIndex].ClearSlot();
Items[slotIndex] = null;
}
UpdateUI();
}
}

View File

@@ -432,9 +432,16 @@ private void JumpAction()
#region
public void PointSitAction(Transform trn)
{
_cController.enabled = false;
_moveInput = Vector2.zero;
_moveTargetDir = Vector3.zero;
_currentSpd = 0f;
_actionExitRequested = false;
_stateMachine.ChangeState(PlayerState.Action);
_anim.SetFloat("speedRatio", 0f);
_anim.SetFloat("DirectX", 0f);
_anim.SetFloat("DirectY", 0f);
_cController.enabled = false;
transform.position = trn.position;
transform.rotation = trn.rotation;
@@ -442,6 +449,18 @@ public void PointSitAction(Transform trn)
_cController.enabled = true;
_anim.SetBool("IsSit",true);
RotationMode = PlayerRotationMode.CameraDecoupled;
float freezeTime = 3f;
_stateMachine.ChangeState(PlayerState.Trans);
_moveCutTimer = freezeTime;
// 앉기 진입 애니메이션 길이에 맞게 조정
_ = Util.RunDelayed(freezeTime, () => {
_stateMachine.ChangeState(PlayerState.Action);
}, default);
}
#endregion
@@ -451,12 +470,12 @@ public void EndAction()
if (_stateMachine.CurrentState != PlayerState.Action) return;
_anim.SetBool("IsSit", false);
float FreezeTime = 2f;
float freezeTime = 2f;
_stateMachine.ChangeState(PlayerState.Trans);
_moveCutTimer = FreezeTime;
_ = Util.RunDelayed(FreezeTime, () => {
_moveCutTimer = freezeTime;
_ = Util.RunDelayed(freezeTime, () => {
_stateMachine.ChangeState(PlayerState.Idle);
RotationMode = PlayerRotationMode.CameraCoupled;
InteractionOnTarget.InteractEnd(this);
@@ -590,12 +609,11 @@ public void AimToggleInput(InputState inputState)
public void InteractInput()
{
if (ActionExitCheck()) return;
if (_stateMachine.CurrentState == PlayerState.Trans) return;
if (InteractionTargets.Count > 0)
{
InteractionOnTarget.InteractExec(this); // 실제 상호작용 실행
RotationMode = PlayerRotationMode.CameraDecoupled;
}
}

View File

@@ -188,14 +188,10 @@ public void OnPointerClick(PointerEventData eventData)
// 우클릭
if (eventData.button == PointerEventData.InputButton.Right)
{
ItemUse();
if(currentItem != null) //아이템이 존재할시에만 사용
{
GameManager.Instance.Inventory.ItemUse(SlotIndex);
}
}
}
public void ItemUse()
{
GameManager.Instance.ItemEffect.ItemUse(currentItem);
currentItem.CurrentStack -= 1;
UpdateSlotUI();
}
}