2026-03-31 물체 상호작용
This commit is contained in:
8
Assets/02_Scripts/Interactions/IInteractable.cs
Normal file
8
Assets/02_Scripts/Interactions/IInteractable.cs
Normal file
@@ -0,0 +1,8 @@
|
||||
using UnityEngine;
|
||||
|
||||
public interface IInteractable
|
||||
{
|
||||
public void InteractOpen();
|
||||
public void InteractClose();
|
||||
public void InteractExec(PlayerCharacterController player);
|
||||
}
|
||||
2
Assets/02_Scripts/Interactions/IInteractable.cs.meta
Normal file
2
Assets/02_Scripts/Interactions/IInteractable.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8a75892d4d295c54e88d2933e38776c4
|
||||
37
Assets/02_Scripts/Interactions/InteractableSit.cs
Normal file
37
Assets/02_Scripts/Interactions/InteractableSit.cs
Normal file
@@ -0,0 +1,37 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.AI;
|
||||
|
||||
public class InteractableSit : MonoBehaviour,IInteractable
|
||||
{
|
||||
private bool interactionOnOff = false;
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if(interactionOnOff)
|
||||
{
|
||||
//메인카메라를 기준으로 좌표 변환
|
||||
Vector3 pos = Camera.main.WorldToScreenPoint(transform.position + Vector3.up * 0.5f);
|
||||
|
||||
//변환된 좌표로 InteractionBox 이동
|
||||
GameManager.Instance.InGameUI.Interaction.UpdateSitBoxPos(pos);
|
||||
}
|
||||
}
|
||||
|
||||
public void InteractOpen()
|
||||
{
|
||||
interactionOnOff = true;
|
||||
GameManager.Instance.InGameUI.Interaction.OnOffSitBox(true);
|
||||
}
|
||||
|
||||
public void InteractClose()
|
||||
{
|
||||
interactionOnOff = false;
|
||||
GameManager.Instance.InGameUI.Interaction.OnOffSitBox(false);
|
||||
}
|
||||
|
||||
public void InteractExec(PlayerCharacterController player)
|
||||
{
|
||||
player.transform.position = gameObject.transform.position;
|
||||
player.transform.rotation = gameObject.transform.rotation;
|
||||
}
|
||||
}
|
||||
2
Assets/02_Scripts/Interactions/InteractableSit.cs.meta
Normal file
2
Assets/02_Scripts/Interactions/InteractableSit.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 36992c9e66ae1344bb485ca8bce2aa5b
|
||||
Reference in New Issue
Block a user