how do I attach a player with a navMeshAgent code example
Example: how do I attach a player with a navMeshAgent
public var player : Transform; function Awake () { player = GameObject.FindGameObjectWithTag ("Player").transform; nav = GetComponent (UnityEngine.AI.NavMeshAgent); } function Update() { var distance = Vector3.Distance(player.position, transform.position); if(distance <= 30) { nav.enabled = true; nav.SetDestination (player.position); } else { this.nav.enabled = false; } }