Created
April 21, 2020 14:02
-
-
Save openroomxyz/3d849ab2f8f1455493a796dca9c3b4ff to your computer and use it in GitHub Desktop.
Unity : How to NavMeshAgent?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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