- Home /
Question by
oinkoinkflapflap · Dec 22, 2011 at 09:33 PM ·
tagtagssendmessage
send message to all objects of a certain tag
says it all in the title really :) how can i send a message to all object in the scene of the tag 'Enemy'
Comment
Best Answer
Answer by FLASHDENMARK · Dec 22, 2011 at 10:06 PM
You use a loop to get each instance and send a message to each of them.
function SendNewMessage(){
var gos : GameObject[];
gos = GameObject.FindGameObjectsWithTag("Enemy");
for(var i = 0; i<gos.length; i++){
gos[i].SendMessage("ApplyDamage", 100);
}
}
//if I wanted ApplyDamage to add a number to a GUI would I do something like this @OrangeLightning ?
function ApplyDamage ()
{
ApplyDamage = dam.toString;
}