コード例 #1
0
 void Awake()
 {
     player       = GameObject.FindGameObjectWithTag("Player").transform;
     playerHealth = player.GetComponent <GlobalHealth> ();
     enemyHealth  = GetComponent <EnemyHealth> ();
     nav          = GetComponent <UnityEngine.AI.NavMeshAgent> ();
 }
コード例 #2
0
    float timer;               // make sure things are happening in sync (enemies arent attack too fast or too slow



    void Awake()
    {
        player       = GameObject.FindGameObjectWithTag("Player");   // gets the player and stores the object locally in the Awake function for use later so references arent always neded.
        playerHealth = player.GetComponent <GlobalHealth> ();
        enemyHealth  = GetComponent <EnemyHealth>();
    }