- Home /
how can I set the destination of the nav mesh for multiple objects
help me !!!!!!!
Answer by tormentoarmagedoom · Sep 24, 2018 at 12:11 PM
Good day.
This is a very poor post. Loo kat at other posts... You spent 10 seconds posting this, and expect someone start coding and give you the answer by spending 10 minutes of its time whn you did not spent that time..
Very bad.
Leran to code, use a simple foreach..
goodbye
Transform coin; UnityEngine.AI.Nav$$anonymous$$eshAgent nav; void Awake () { coin = GameObject.FindGameObjectWithTag("$$anonymous$$oney").transform;
nav = GetComponent <UnityEngine.AI.Nav$$anonymous$$eshAgent> ();
} void Update () { nav.SetDestination (coin.position); //} //else //{ // nav.enabled = false; //} }
this is the script you can help me thanks anyway!!!!
Answer by ric_tecnology · Sep 26, 2018 at 04:46 PM
Transform coin; //PlayerHealth playerHealth; //EnemyHealth enemyHealth; UnityEngine.AI.NavMeshAgent nav; void Awake () { coin = GameObject.FindGameObjectWithTag("Money").transform; //playerHealth = player.GetComponent (); //enemyHealth = GetComponent (); nav = GetComponent (); } void Update () { //if(enemyHealth.currentHealth > 0 && playerHealth.currentHealth > 0) //{ nav.SetDestination (coin.position); //} //else //{ // nav.enabled = false; //} }