I’m attempting to follow some of the BergZerg tutorials and I’m on the targeting section right now. Unfortunately I cannot seem to get my script to add any tagged objects. All my enemy objects are tagged with the tag Enemy and I am using the code below. I have even tried to change the tag to Player and it did not pick the player. I created a new tag “enemy” with the lower case “e” and it still did not pick it up. I’m at a loss.
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
public class Targeting : MonoBehaviour {
public List<Transform> targets;
// Use this for initialization
void Start () {
targets = new List<Transform>();
}
//Add enemies to array
public void AddAllEnemies(){
GameObject[] go = GameObject.FindGameObjectsWithTag("Enemy");
foreach(GameObject enemy in go)
AddTarget(enemy.transform );
}
// Add enemies to player target
public void AddTarget(Transform enemy){
targets.Add(enemy);
}
// Update is called once per frame
void Update () {
}
}