using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.AI;
public class NavUniControl : MonoBehaviour
{
public Transform goal;
private NavMeshAgent agent;
private Animator animator;
// Start is called before the first frame update
void Start()
{
agent = GetComponent();
agent.destination = goal.position;
animator = GetComponent<Animator>();
}
// Update is called once per frame
void Update()
{
agent.destination = goal.position;
if (agent.remainingDistance < agent.stoppingDistance)
{
animator.SetBool("walk", false);
agent.isStopped = true;
}
else if (agent.remainingDistance > agent.stoppingDistance + 0.5f)
{
animator.SetBool("walk", true);
agent.isStopped = false;
}
}
}