육지도착

This commit is contained in:
2026-06-22 16:58:32 +09:00
parent f7a71e11d6
commit 74afff5be8
23 changed files with 1500 additions and 54 deletions

View File

@@ -0,0 +1,85 @@
using System.Collections;
using UnityEngine;
using UnityEngine.XR.Interaction.Toolkit.Interactables;
public class MemoryFragmentReset : MonoBehaviour
{
[Header("References")]
[SerializeField] private XRGrabInteractable grabInteractable;
[SerializeField] private Rigidbody rb;
[Header("Reset")]
[SerializeField] private Transform resetPoint;
[Tooltip("리셋 후 다시 잡을 수 있게 되기까지의 시간")]
[SerializeField] private float reEnableDelay = 0.15f;
[Header("Debug")]
[SerializeField] private bool showDebugLog = true;
private Vector3 startPosition;
private Quaternion startRotation;
private Transform startParent;
private Coroutine resetRoutine;
private void Awake()
{
if (grabInteractable == null)
grabInteractable = GetComponent<XRGrabInteractable>();
if (rb == null)
rb = GetComponent<Rigidbody>();
startPosition = transform.position;
startRotation = transform.rotation;
startParent = transform.parent;
}
public void ResetFragment()
{
if (resetRoutine != null)
StopCoroutine(resetRoutine);
resetRoutine = StartCoroutine(ResetRoutine());
}
private IEnumerator ResetRoutine()
{
if (grabInteractable != null)
grabInteractable.enabled = false;
if (rb != null)
{
rb.linearVelocity = Vector3.zero;
rb.angularVelocity = Vector3.zero;
rb.isKinematic = true;
}
transform.SetParent(startParent, true);
if (resetPoint != null)
{
transform.position = resetPoint.position;
transform.rotation = resetPoint.rotation;
}
else
{
transform.position = startPosition;
transform.rotation = startRotation;
}
yield return new WaitForSeconds(reEnableDelay);
if (rb != null)
rb.isKinematic = false;
if (grabInteractable != null)
grabInteractable.enabled = true;
if (showDebugLog)
Debug.Log("[MemoryFragmentReset] 기억의 조각을 원래 위치로 되돌렸습니다.", this);
resetRoutine = null;
}
}