using UnityEngine; using System.Collections; public class Pathfinding : MonoBehaviour { public Transform target; NavMeshAgent agent; // Use this for initialization void Start () { agent = GetComponent (); } // Update is called once per frame void Update () { agent.SetDestination (target.position); } }