32 lines
734 B
C#
32 lines
734 B
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.AI;
|
|
|
|
namespace Beyond
|
|
{
|
|
public class AgentControl : MonoBehaviour
|
|
{
|
|
public Transform target;
|
|
|
|
private Vector3 prevTarget;
|
|
private NavMeshAgent navMeshAgent;
|
|
|
|
// Start is called before the first frame update
|
|
void Start()
|
|
{
|
|
navMeshAgent = GetComponent<NavMeshAgent>();
|
|
}
|
|
|
|
// Update is called once per frame
|
|
void Update()
|
|
{
|
|
if (prevTarget != target.transform.position)
|
|
{
|
|
prevTarget = target.transform.position;
|
|
navMeshAgent.SetDestination(prevTarget);
|
|
}
|
|
}
|
|
}
|
|
}
|