3 Capitalized Pronouns
source | link

iI am trying to make a game using navmeshNavMesh agent in unityUnity,where where the enemies first attack the player and change their target to tanks when player spawns them.then Then again retarget player after the tank dies,have have no uideaidea how to do this as tank is not in game initially and cannot check it in awake.

using UnityEngine;
using System.Collections;

public class enmymove : MonoBehaviour {

Transform player;
NavMeshAgent nav;
healthscript Health;
Animator anim;
public GameObject GORTLE;
Transform Gortle;
Gortlehealth Ghealth;


void Awake ()
{
    player=GameObject.FindGameObjectWithTag ("Player").transform;
    nav = GetComponent<NavMeshAgent>();
    Health =player.GetComponent<healthscript> ();
    anim = GetComponent<Animator>();
    //Gortle = GameObject.FindGameObjectWithTag ("Gortle").transform;
    //Ghealth = Gortle.GetComponent<Gortlehealth> ();
}


void Update ()
{

    if (Ghealth.currenthealth > 0 ) 
    {

        nav.SetDestination (Gortle.position);

    }
    else 
    {
        if (Health.currenthealth > 0 && Ghealth.currenthealth <= 0 ) 
        {
            nav.SetDestination (player.position);
        }
        else
        {
            GetComponent<NavMeshAgent> ().enabled = false;
            anim.SetTrigger ("idle");
        }
    }
 }
 }

i am trying to make a game using navmesh agent in unity,where the enemies first attack the player and change their target to tanks when player spawns them.then again retarget player after the tank dies,have no uidea how to do this as tank is not in game initially and cannot check it in awake.

using UnityEngine;
using System.Collections;

public class enmymove : MonoBehaviour {

Transform player;
NavMeshAgent nav;
healthscript Health;
Animator anim;
public GameObject GORTLE;
Transform Gortle;
Gortlehealth Ghealth;


void Awake ()
{
    player=GameObject.FindGameObjectWithTag ("Player").transform;
    nav = GetComponent<NavMeshAgent>();
    Health =player.GetComponent<healthscript> ();
    anim = GetComponent<Animator>();
    //Gortle = GameObject.FindGameObjectWithTag ("Gortle").transform;
    //Ghealth = Gortle.GetComponent<Gortlehealth> ();
}


void Update ()
{

    if (Ghealth.currenthealth > 0 ) 
    {

        nav.SetDestination (Gortle.position);

    }
    else 
    {
        if (Health.currenthealth > 0 && Ghealth.currenthealth <= 0 ) 
        {
            nav.SetDestination (player.position);
        }
        else
        {
            GetComponent<NavMeshAgent> ().enabled = false;
            anim.SetTrigger ("idle");
        }
    }
 }
 }

I am trying to make a game using NavMesh agent in Unity, where the enemies first attack the player and change their target to tanks when player spawns them. Then again retarget player after the tank dies, have no idea how to do this as tank is not in game initially and cannot check it in awake.

using UnityEngine;
using System.Collections;

public class enmymove : MonoBehaviour {

Transform player;
NavMeshAgent nav;
healthscript Health;
Animator anim;
public GameObject GORTLE;
Transform Gortle;
Gortlehealth Ghealth;


void Awake ()
{
    player=GameObject.FindGameObjectWithTag ("Player").transform;
    nav = GetComponent<NavMeshAgent>();
    Health =player.GetComponent<healthscript> ();
    anim = GetComponent<Animator>();
    //Gortle = GameObject.FindGameObjectWithTag ("Gortle").transform;
    //Ghealth = Gortle.GetComponent<Gortlehealth> ();
}


void Update ()
{

    if (Ghealth.currenthealth > 0 ) 
    {

        nav.SetDestination (Gortle.position);

    }
    else 
    {
        if (Health.currenthealth > 0 && Ghealth.currenthealth <= 0 ) 
        {
            nav.SetDestination (player.position);
        }
        else
        {
            GetComponent<NavMeshAgent> ().enabled = false;
            anim.SetTrigger ("idle");
        }
    }
 }
 }
2 fix indentation
source | link

i am trying to make a game using navmesh agent in unity,where the enemies first attack the player and change their target to tanks when player spawns them.then again retarget player after the tank dies,have no uidea how to do this as tank is not in game initially and cannot check it in awake.

using UnityEngine;
using System.Collections;

public class enmymove : MonoBehaviour {

Transform player;
NavMeshAgent nav;
healthscript Health;
Animator anim;
public GameObject GORTLE;
Transform Gortle;
Gortlehealth Ghealth;


void Awake ()
{
    player=GameObject.FindGameObjectWithTag ("Player").transform;
    nav = GetComponent<NavMeshAgent>();
    Health =player.GetComponent<healthscript> ();
    anim = GetComponent<Animator>();
    //Gortle = GameObject.FindGameObjectWithTag ("Gortle").transform;
    //Ghealth = Gortle.GetComponent<Gortlehealth> ();
}


void Update ()  
{

    if (Ghealth.currenthealth > 0 ) 
    {

        nav.SetDestination (Gortle.position);

    }
    else 
    {
        if (Health.currenthealth > 0 && Ghealth.currenthealth <= 0 ) 
        {
            nav.SetDestination (player.position);
        }
        else
        {
            GetComponent<NavMeshAgent> ().enabled = false;
            anim.SetTrigger ("idle");
        }
 
    }
 }
 }

i am trying to make a game using navmesh agent in unity,where the enemies first attack the player and change their target to tanks when player spawns them.then again retarget player after the tank dies,have no uidea how to do this as tank is not in game initially and cannot check it in awake.

using UnityEngine;
using System.Collections;

public class enmymove : MonoBehaviour {

Transform player;
NavMeshAgent nav;
healthscript Health;
Animator anim;
public GameObject GORTLE;
Transform Gortle;
Gortlehealth Ghealth;


void Awake ()
{
    player=GameObject.FindGameObjectWithTag ("Player").transform;
    nav = GetComponent<NavMeshAgent>();
    Health =player.GetComponent<healthscript> ();
    anim = GetComponent<Animator>();
    //Gortle = GameObject.FindGameObjectWithTag ("Gortle").transform;
    //Ghealth = Gortle.GetComponent<Gortlehealth> ();
}


void Update () {

    if (Ghealth.currenthealth > 0 ) 
    {

        nav.SetDestination (Gortle.position);

    }
    else 
    { if (Health.currenthealth > 0 && Ghealth.currenthealth <= 0 ) 
        {
            nav.SetDestination (player.position);
        }
        else
    {
        GetComponent<NavMeshAgent> ().enabled = false;
        anim.SetTrigger ("idle");
    }
 
    }
 }
 }

i am trying to make a game using navmesh agent in unity,where the enemies first attack the player and change their target to tanks when player spawns them.then again retarget player after the tank dies,have no uidea how to do this as tank is not in game initially and cannot check it in awake.

using UnityEngine;
using System.Collections;

public class enmymove : MonoBehaviour {

Transform player;
NavMeshAgent nav;
healthscript Health;
Animator anim;
public GameObject GORTLE;
Transform Gortle;
Gortlehealth Ghealth;


void Awake ()
{
    player=GameObject.FindGameObjectWithTag ("Player").transform;
    nav = GetComponent<NavMeshAgent>();
    Health =player.GetComponent<healthscript> ();
    anim = GetComponent<Animator>();
    //Gortle = GameObject.FindGameObjectWithTag ("Gortle").transform;
    //Ghealth = Gortle.GetComponent<Gortlehealth> ();
}


void Update () 
{

    if (Ghealth.currenthealth > 0 ) 
    {

        nav.SetDestination (Gortle.position);

    }
    else 
    {
        if (Health.currenthealth > 0 && Ghealth.currenthealth <= 0 ) 
        {
            nav.SetDestination (player.position);
        }
        else
        {
            GetComponent<NavMeshAgent> ().enabled = false;
            anim.SetTrigger ("idle");
        }
    }
 }
 }
1
source | link

Enemy Retargeting

i am trying to make a game using navmesh agent in unity,where the enemies first attack the player and change their target to tanks when player spawns them.then again retarget player after the tank dies,have no uidea how to do this as tank is not in game initially and cannot check it in awake.

using UnityEngine;
using System.Collections;

public class enmymove : MonoBehaviour {

Transform player;
NavMeshAgent nav;
healthscript Health;
Animator anim;
public GameObject GORTLE;
Transform Gortle;
Gortlehealth Ghealth;


void Awake ()
{
    player=GameObject.FindGameObjectWithTag ("Player").transform;
    nav = GetComponent<NavMeshAgent>();
    Health =player.GetComponent<healthscript> ();
    anim = GetComponent<Animator>();
    //Gortle = GameObject.FindGameObjectWithTag ("Gortle").transform;
    //Ghealth = Gortle.GetComponent<Gortlehealth> ();
}


void Update () {

    if (Ghealth.currenthealth > 0 ) 
    {

        nav.SetDestination (Gortle.position);

    }
    else 
    { if (Health.currenthealth > 0 && Ghealth.currenthealth <= 0 ) 
        {
            nav.SetDestination (player.position);
        }
        else
    {
        GetComponent<NavMeshAgent> ().enabled = false;
        anim.SetTrigger ("idle");
    }

    }
 }
 }