target and look at random enemies

I'm not exectly sure on how to have an object look at a random target. I know i have to use the


or something like that. But the things i want it to target all have the same name. They are all named "Enemy(Clone)". How do I make the object look at a random enemy when they all have the same name?.

Use FindGameObjectsWithTag. Make sure you have all your enemies tagged and then do something like this...

//an array of gameObjects
var enemies : GameObject[];
//the target
var theTarget : GameObject;

var rand;

//a function to look at a random enemy
function LookAtRandomEnemy(){
//fill the array with all gameobjects tagged with Enemy
enemies = GameObject.FindGameObjectsWithTag("Enemy");

//A random number between 1 and the number of enemies
rand = Random.Range(1, enemies.Length)

//set the target as the enemy at the position rand in the array
theTarget = enemies[rand];

//look at the target

Now just call this when you want to look at a random enemy.