본문 바로가기
GGM/엔진

20230327 - 엔진 - Navigation

by DDongYeop 2023. 3. 29.
728x90

 

Navigation

 

Agents

 - Name : 객체의 이름

 - Radius : 객체의 크기

 - Height : 객체의 높이 

 - Step Height : 올라갈수 있는 높이 

 - Max Slope : 올라갈 수 있는 경사도 

 

Bake

 Agents와 비슷하지만 실제 맵에 갈 수 있는 곳 그려

 

 

Nav Mesh Obstacle

 - Curve : Nav Mehs에 영향을 줄지 선택하는 것 

 - Carve only Stationary : 선택하면 움직일때는 Bake하지 않음. 체크할시 연산이 많이 됨 

 

 

미리 받아둔 오브젝트의 위치로 가게 되는 코드 

using UnityEngine;
using UnityEngine.AI;

public class ChaseNavAgent : MonoBehaviour
{
    [SerializeField] private Transform _targetTrm;

    private NavMeshAgent _agent;

    private void Awake()
    {
        _agent = GetComponent<NavMeshAgent>();
    }

    private void Update()
    {
        if (Input.GetButtonDown("Jump"))
        {
            Vector3 pos = _targetTrm.position;
            pos.y = transform.position.y;
            _agent.SetDestination(pos);
        }
    }
}
728x90

댓글