FPSGame/Assets/Enemies/EnemyAI.cs

23 lines
473 B
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.AI;
public class EnemyAI : MonoBehaviour
{
[SerializeField] Transform target;
NavMeshAgent navMeshAgent;
// Start is called before the first frame update
void Start()
{
navMeshAgent = GetComponent<NavMeshAgent>();
}
// Update is called once per frame
void Update()
{
navMeshAgent.SetDestination(target.position);
}
}