using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.AI;
public class Xunlu : MonoBehaviour
{
public Transform[] DirectPoints;
private int _index = 0;
private float _timer = 0;
public float patroTime = 2f;
[SerializeField]
private NavMeshAgent _nav;
public Animator _animator;
private void Awake()
{
if (!_nav)
_nav.GetComponent<NavMeshAgent>();
_nav.destination = DirectPoints[_index].position;
}
private void Update()
{
GoTheRounds();
}
private void GoTheRounds()
{
if (_nav.remainingDistance < 0.5f)
{
_timer += Time.deltaTime;
if (_timer >= patroTime)
{
_index++;
_index %= 2;
_timer = 0;
_nav.destination = DirectPoints[_index].position;
}
}
}
}
烘培地面 给人物添加人物控制器 赋值 完事