드디어 완성
This commit is contained in:
@@ -5,8 +5,27 @@ public class KimchiHitZone : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private UnityEvent onKimchiHit;
|
||||
|
||||
private Collider hitCollider;
|
||||
private bool hasBeenHit;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
hitCollider = GetComponent<Collider>();
|
||||
|
||||
if (hitCollider != null)
|
||||
hitCollider.enabled = false;
|
||||
}
|
||||
|
||||
public void Arm()
|
||||
{
|
||||
hasBeenHit = false;
|
||||
|
||||
if (hitCollider != null)
|
||||
hitCollider.enabled = true;
|
||||
|
||||
Debug.Log("김치싸대기 판정 활성화");
|
||||
}
|
||||
|
||||
private void OnTriggerEnter(Collider other)
|
||||
{
|
||||
if (hasBeenHit)
|
||||
@@ -16,6 +35,10 @@ private void OnTriggerEnter(Collider other)
|
||||
return;
|
||||
|
||||
hasBeenHit = true;
|
||||
|
||||
if (hitCollider != null)
|
||||
hitCollider.enabled = false;
|
||||
|
||||
onKimchiHit?.Invoke();
|
||||
|
||||
Debug.Log("김치싸대기 성공!");
|
||||
|
||||
@@ -1,22 +0,0 @@
|
||||
using UnityEngine;
|
||||
|
||||
public class ResetChildLocalRotation : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private Transform target;
|
||||
|
||||
private Quaternion initialLocalRotation;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
if (target != null)
|
||||
initialLocalRotation = target.localRotation;
|
||||
}
|
||||
|
||||
public void ResetRotation()
|
||||
{
|
||||
if (target == null)
|
||||
return;
|
||||
|
||||
target.localRotation = initialLocalRotation;
|
||||
}
|
||||
}
|
||||
@@ -1,2 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8f701eb628e084b4f87b750c2716f6f5
|
||||
36
Assets/02_Scripts/Story/ch3/XRMoveToPoint.cs
Normal file
36
Assets/02_Scripts/Story/ch3/XRMoveToPoint.cs
Normal file
@@ -0,0 +1,36 @@
|
||||
using UnityEngine;
|
||||
using Unity.XR.CoreUtils;
|
||||
|
||||
public class XRMoveToPoint : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private XROrigin xrOrigin;
|
||||
[SerializeField] private Transform targetPoint;
|
||||
|
||||
public void MoveNow()
|
||||
{
|
||||
if (xrOrigin == null || targetPoint == null)
|
||||
return;
|
||||
|
||||
// 현재 카메라를 목표 위치로 이동
|
||||
xrOrigin.MoveCameraToWorldLocation(targetPoint.position);
|
||||
|
||||
// 카메라가 목표 지점의 앞 방향을 바라보게 회전
|
||||
Vector3 currentForward = xrOrigin.Camera.transform.forward;
|
||||
currentForward.y = 0f;
|
||||
|
||||
Vector3 targetForward = targetPoint.forward;
|
||||
targetForward.y = 0f;
|
||||
|
||||
if (currentForward.sqrMagnitude > 0.001f &&
|
||||
targetForward.sqrMagnitude > 0.001f)
|
||||
{
|
||||
float angle = Vector3.SignedAngle(
|
||||
currentForward,
|
||||
targetForward,
|
||||
Vector3.up
|
||||
);
|
||||
|
||||
xrOrigin.RotateAroundCameraUsingOriginUp(angle);
|
||||
}
|
||||
}
|
||||
}
|
||||
2
Assets/02_Scripts/Story/ch3/XRMoveToPoint.cs.meta
Normal file
2
Assets/02_Scripts/Story/ch3/XRMoveToPoint.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d7fca78410463b746b88db2efc67f4af
|
||||
Reference in New Issue
Block a user