🔷 ARCore - 로그캣
- monster가 camera를 따라오도록 처리
- 로그캣
🔶 monster가 camera를 따라오도록 처리

- 스크립트 생성 : MonsterMove
- monster 프리팹에 추가
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class MonsterMove : MonoBehaviour
{
private Transform camTr;
public float moveSpeed = 0.2f;
void Start()
{
camTr = Camera.main.transform;
}
void Update()
{
Debug.Log($"transform = {transform.position.x}, {transform.position.y}, {transform.position.z}");
// 회전
Vector3 dir = (camTr.position - transform.position);
dir.y = 0;
Quaternion rot = Quaternion.LookRotation(dir);
transform.rotation = Quaternion.Slerp(transform.rotation, rot, Time.deltaTime * 5.0f);
// 이동
transform.Translate(Vector3.forward * Time.deltaTime * moveSpeed);
}
}
-
🔶 로그캣
- 디버깅을 위해 로그를 찍어보고싶을 때, 사용하면 유용함

- 패키지매니저 > Android Logcat 설치

- Window > Analysis > Logcat

- Tag 우클릭 > Unity 클릭
- 유니티 관련 로그만 볼 수 있도록 필터링
🔶 Build & Run

- 몬스터가 잘 따라옴

- 로그캣에 로그가 찍힘
'Unity > AR' 카테고리의 다른 글
06. ARCore - 자 만들기 (0) | 2021.09.15 |
---|---|
05. ARCore - Face Tracking (0) | 2021.09.14 |
03. ARCore - 바닥 인식, 오브젝트 생성 (1) | 2021.09.11 |
02. ARCore - Feature point 시각화 (0) | 2021.09.09 |
01. ARCore - 설치 (0) | 2021.09.07 |