twinStick/twinStickCrawler/Assets/Scripts/Enemy/EnemyMove.cs
2024-12-08 14:40:51 +01:00

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);
}
}