ARFoundation 평면 탐지, Ray 비행을 통해 캐릭터 표시
                                            
                                                
                                                
                                                
                                                
                                                
                                                 5959 단어  ARFoundation
                    
 
 Character 사전 제작, 등급 제도에서의 Character 삭제
 
 ARRRaycastManager를 ARSession Origin에 추가
 
 RayCast.제작 cs
 
 Raycast
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 평면 탐지, Ray 비행을 통해 캐릭터 표시), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://qiita.com/bu-ta/items/5123f974d625e4d3691d텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
                                
                                
                                
                                
                                
                                우수한 개발자 콘텐츠 발견에 전념
                                (Collection and Share based on the CC Protocol.)