22 lines
824 B
C#
22 lines
824 B
C#
using UnityEngine;
|
|
using UnityEngine.AI;
|
|
|
|
public class EnemyMove : MonoBehaviour
|
|
{
|
|
public GameObject player;
|
|
|
|
private NavMeshAgent _meshAgent;
|
|
// Start is called once before the first execution of Update after the MonoBehaviour is created
|
|
void Start()
|
|
{
|
|
_meshAgent = GetComponent<NavMeshAgent>();
|
|
}
|
|
|
|
// Update is called once per frame
|
|
void Update()
|
|
{
|
|
Vector3 playerPos = player.transform.position;
|
|
|
|
_meshAgent.SetDestination(playerPos);
|
|
}
|
|
} |