ARFoundation 평면에 구멍을 뚫어요.
6992 단어 ARFoundation


내부 Cube에서 Material 제작 및 설정

캐릭터를 안에 배치하다

벽에 아욱을 설정했기 때문에 캐릭터의 RenderQue를 2001(표시 순서를 결정하기 위해)

외부 Cube를 사용하여 Spatial Mapping Occlusion 설정

설정 완료 후 프로덕터로 설정

Fade용 Material 및 AR DefaultPlane Element 포함

Hole, Mask, Character 높이 조정

AR Session Origin의 Raycast 스크립트에서 Hole 프리셋 설정

Raycast.cs아래와 같이↓
Raycast.cs
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.XR.ARFoundation;
using UnityEngine.XR.ARSubsystems;
public class Raycast : MonoBehaviour
{
//Raycast を実行するためのクラス
private ARRaycastManager m_RaycastManager;
//Raycast の結果を格納する List
private List<ARRaycastHit> hitResults = new List<ARRaycastHit>();
//キャラクターの Prefab
[SerializeField]
private GameObject characterPrefab;
void Start()
{
//GameObject にアタッチされている RaycastManager を取得
m_RaycastManager = GetComponent<ARRaycastManager>();
}
void Update()
{
//画面がタッチされたら処理を行う
if (Input.touchCount > 0)
{
//画面タッチの情報を取得する
Touch touch = Input.GetTouch(0);
//画面タッチの開始時のみ処理を行う
if (touch.phase == TouchPhase.Began)
{
//タッチした方向に Ray を飛ばし、平面との衝突判定を行う
if (m_RaycastManager.Raycast(
touch.position,
hitResults,
TrackableType.PlaneWithinPolygon
))
{
//最初に交差した平面から姿勢を取得して、GameObject を生成する
Pose hitPose = hitResults[0].pose;
GameObject character = Instantiate(
characterPrefab,
hitPose.position,
hitPose.rotation
);
}
}
}
}
}
Reference
이 문제에 관하여(ARFoundation 평면에 구멍을 뚫어요.), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://qiita.com/bu-ta/items/5ba2f550fc92b1691e88텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념
(Collection and Share based on the CC Protocol.)