Assign all GameObjects with tag "x" to a different Layer?

Hey guys!

I’m trying to make it so that when my player is damaged, all the enemies with the tag “Enemy” switch to a different layer.

I’ve tried messing around with FindGameObjectsWithTag"Enemy" but I can’t figure out the proper way to script it.

Any help would be very much appreciated :0)

Hi men to do this you need to use a array because FindGameObjectsWithTag return a array of type GameObject and after we asign to elements of this array the number of the layer that we want to asign to them :

GameObject[] enemies = GameObject.FindGameObjectsWithTag ("Enemy");
foreach (GameObject enemy in enemies)
{
	enemy.layer = 2;
}

I hope I help, Sean.