✳ Navigation(Nav Meth) : 내비 매쉬
◾ Nav Mesh Agent
→ 이 컴퍼넌트가 있는 오브젝트만 길찾기 알고리즘을 사용할 수 있음
→ Angular Speed : 높을수록 전환이 빨라짐
◾ C# Mover
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.AI;
public class Mover : MonoBehaviour
{
[SerializeField] NavMeshAgent agent;
private void Awake()
{
agent= GetComponent<NavMeshAgent>();
}
void Update()
{
if (Input.GetMouseButtonDown(0))
{
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
if (Physics.Raycast(ray, out RaycastHit hit))
{
agent.SetDestination(hit.point);
}
}
}
}
→ 스크립트를 Player 에 집어넣기
→ 실행 후 마우스로 클릭하면 그 방향으로 움직임
◾ Nav Mesh Obstacle (장애물)
→ 더 이상 관통해서 지나갈 수 없음
→ 만약 Navigation Static 을 사용하지 못할 경우 사용
◾ NavMeshSurface (고급 버전)
→ 기존과 동일하게 Bake 를 누르면 밑에 NavMesh 가 생성됩니다.