Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CSHARP

unity navmeshagent set destination

// To use this script, you need a set-up navmesh surface.
// Attach this script onto a navmesh agent.

using UnityEngine;
using UnityEngine.AI;

public class SetDestination : MonoBehaviour {
  public Transform target;
  
  NavMeshAgent agent = GetComponent<NavMeshAgent>();
  
  void Update(){
    agent.SetDestination(target.position);
  }
}
 
PREVIOUS NEXT
Tagged: #unity #navmeshagent #set #destination
ADD COMMENT
Topic
Name
5+3 =