How to make multiple targets?

How can I make multiple targets for one attacker? Since I want to design a attacker within a game, I want to set multiple targets for the attacker. These targets are with different tags. How can I do this?

The best way to do this is to use the tags, but, if your targets have different tags, I can't see another way than this:

  • Make a gameobject that will be your "targets control";
  • Make in this control a array that will store your targets transforms;
  • Make your targets to be "registered" in this control when created;
  • Make your targets to be "unregistered" in this control when destroyed;

A little and simple example:

To control;

var targets = new Array();
function registerTarget(tr : Transform){
    targets.Push(tr);
}

To targets:

function Start(){
    var targetsControl = GameObject.Find("/TargetsControl");
    targetsControl.GetComponent(TargetControlScript).registerTarget(transform);
}