twinStick/twinStickCrawler/Assets/Scripts/Enemy/EnemyMove.cs

22 lines
824 B
C#
Raw Normal View History

2024-12-08 13:40:51 +00:00
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);
}
}