ARFoundation으로 ARCore 사용하기 - 객체를 중심으로 세상을 이동
arSessionOrigin.MakeContentAppearAt에 대해 알아 보겠습니다.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.XR.ARFoundation;
using UnityEngine.XR.ARSubsystems;
public class MoveARWorldPivot : MonoBehaviour
{
public Transform target;
public ARRaycastManager arRaycastManager;
public ARSessionOrigin arSessionOrigin;
private List<ARRaycastHit> hits = new List<ARRaycastHit>();
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
if (Input.touchCount == 0)
{
return;
}
Touch touch = Input.GetTouch(0);
if (arRaycastManager.Raycast(touch.position, hits, TrackableType.Planes))
{
Pose hitPose = hits[0].pose;
arSessionOrigin.MakeContentAppearAt(target, hitPose.position, hitPose.rotation);
}
}
}
arSessionOrigin.MakeContentAppearAt 을 사용하게 되면 유니티 상의 Target 객체의 좌표는 그대로 이고 ARARSessionOrigin이 Target 객체에 맞춰 이동하게 됩니다.
AR을 할때 중요한 이슈이니 꼭 기억합시다.
'Unity > ARCore' 카테고리의 다른 글
ARFoundation으로 ARCore 사용하기 - 이미지 트래킹 (0) | 2020.10.28 |
---|---|
ARFoundation으로 ARCore 사용하기 - ARPlaneManagerEvent (0) | 2020.10.28 |
ARFoundation으로 ARCore 사용하기 - 세션 상태 (0) | 2020.10.27 |
ARFoundation으로 ARCore 사용하기 - PointCloud, Plane Manager (0) | 2020.10.27 |
ARFoundation으로 ARCore 사용하기 - 바닥면에 객체 생성 (0) | 2020.10.27 |