Skip to content

Instantly share code, notes, and snippets.

@openroomxyz
Created April 21, 2020 14:02
Show Gist options
  • Save openroomxyz/3d849ab2f8f1455493a796dca9c3b4ff to your computer and use it in GitHub Desktop.
Save openroomxyz/3d849ab2f8f1455493a796dca9c3b4ff to your computer and use it in GitHub Desktop.
Unity : How to NavMeshAgent?
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.AI;
public class EnemyAI : MonoBehaviour
{
[SerializeField] Transform target; // We care where player is.
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);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment