Class ARPlaneManager | AR Foundation | 5.0.7
Class ARPlaneManager A manager for ARPlanes. Creates, updates, and removes GameObjects in response to detected surfaces in the physical environment. Inherited Members UnityEngine.MonoBehaviour.IsInvoking() UnityEngine.MonoBehaviour.CancelInvoke() UnityEngi
docs.unity3d.com
https://docs.unity3d.com/Packages/com.unity.xr.arfoundation@5.0/manual/features/features.html
Features | AR Foundation | 5.0.7
Features AR Foundation supports the following features: Feature Description Session Enable, disable, and configure AR on the target platform. Device tracking Track the device's position and rotation in physical space. Camera Render images from device camer
docs.unity3d.com
SRDebugger - 안드로이드에서 로그를 볼 수 있음
XR Origin에 Camera가 있어서 Main Camera는 삭제
XR Origin에 AR Plane Manager 추가하고 Detection Mode를 Horizontal로 변경
DetectedPlane이라는 빈 오브젝트 추가하고 Mesh Renderer, Filter, Collider, AR Plane Mesh Visualizer[이거 추가하면 AR Plane 자동으로 추가] 추가
Material 추가, Rendering Mode - Transparent [반투명으로 보이게] , Color.A 값 166으로 수정
카메라 안 켜질 때 IL2CPP랑 ARM64 체크
Indicator.png
M_Indicator의 Albedo에 드래그 앤 드롭
Quad를 만들어주고 이름을 Indicator로 변경, Materials에 M_Indicator 넣기
CarManager 스크립트 추가, XR Origin에 추가
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.XR.ARFoundation;
using UnityEngine.XR.ARSubsystems;
public class CarManager : MonoBehaviour
{
[SerializeField] private GameObject indicatorGo;
[SerializeField] private ARRaycastManager arManager;
[SerializeField] private GameObject carPrefab;
private GameObject carGo;
// Start is called before the first frame update
void Start()
{
this.indicatorGo.SetActive(false);
}
// Update is called once per frame
void Update()
{
this.DetectGround();
if(this.indicatorGo.activeInHierarchy && Input.touchCount > 0)
{
Touch touch = Input.GetTouch(0);
if(touch.phase == TouchPhase.Began)
{
if(this.carGo == null)
{
this.carGo = Instantiate(this.carPrefab, this.indicatorGo.transform.position, this.indicatorGo.transform.rotation);
}
else
{
this.carGo.transform.SetPositionAndRotation(indicatorGo.transform.position, indicatorGo.transform.rotation);
}
}
}
}
private void DetectGround()
{
Vector2 screenSize = new Vector2(Screen.width * 0.5f, Screen.height * 0.5f); // 스크린의 중앙
List<ARRaycastHit> hitInfos = new List<ARRaycastHit>();
if(this.arManager.Raycast(screenSize, hitInfos, TrackableType.Planes))
{
this.indicatorGo.SetActive(true);
this.indicatorGo.transform.position = hitInfos[0].pose.position; // world
this.indicatorGo.transform.rotation = hitInfos[0].pose.rotation;
this.indicatorGo.transform.position += this.indicatorGo.transform.up * 0.1f;
}
else
{
this.indicatorGo.SetActive(false);
}
}
}
https://assetstore.unity.com/packages/3d/vehicles/land/arcade-free-racing-car-161085
ARCADE: FREE Racing Car | 3D 지상 | Unity Asset Store
Elevate your workflow with the ARCADE: FREE Racing Car asset from Mena. Find this & other 지상 options on the Unity Asset Store.
assetstore.unity.com
'AR 콘텐츠 기초' 카테고리의 다른 글
[AR Foundation] 단일 마커 인식 방식 (0) | 2023.11.06 |
---|---|
[AR Foundation] ARTrackable, ARFace, ARFaceManager, trackingState, tracking (0) | 2023.11.03 |
[AR Foundation] 얼굴 인식 (1) | 2023.11.02 |
[AR Foundation] 자동차 터치 스와이프로 모델링 회전, 스마트폰에서 앱 실행 중에 꺼짐 방지, ScrollView, Content, 자동차 색 변경, 자동차 색 변경 시 위치 안따라오기 (0) | 2023.11.02 |
[AR Foundation] 준비과정 (0) | 2023.11.01 |