Animation only plays in one of the objects

Hello…
I have an script when I click it will play an animation, I have cloned the Game Objects that have the animation, but for some reason only ONE of the objects will play the animation.

alt text

The object “Beacon” it’s the one with the animation, I have them with a tag “Beacon”

GameObject.FindWithTag("Beacon").GetComponent<Animation>().Play();

That is the line of script that calls the animation, but for some reason only one of the objects plays the animation the other two don’t do anything.

thank you (and sorry for bad english)

Hi,

this line tells to find the first object with the tag “Beacon”.
You can use

GameObject[] obj = GameObject.FindGameObjectsWithTag ("Beacon");
if (obj.Length > 0)
{
    for (int i = 0 ; i < obj.Length ; i++)
    {
        Animation a = obj*.GetComponent<Animation>();*

if (a)
a.Play();
}
}
That said, it would be better to use this, if you don’t have other Animation within the hierarchy.
Animation[] animations = GetComponentsInChildren();
if (animations.Length > 0)
for (int i = 0 ; i < animations.Length ; i++)
animations*.Play();*