0
\$\begingroup\$

I'm using unity 5

I'm trying to animate multiple child objects via a parent object. The animation worked in the animation view but would not work when I tried to preview the game. In the script I use the code:

ParentObject.GetComponent<Animator>().Play("intro");

to play the animation. A similar line of code worked when playing a singular object, not sure what's going wrong now, any sugestions?

\$\endgroup\$
10
  • \$\begingroup\$ Can you show your animator window? \$\endgroup\$
    – Nikaas
    Jun 11, 2017 at 6:57
  • \$\begingroup\$ I got the animation to work by setting the update mode to normal in Start(). I have two animations that should be running and only one will run. I assume this has something to do with both animator components having animations on their respective base layers...is that right....one animation acts on the parent (which animates all the children), the other acts on a single child object.. \$\endgroup\$
    – Joel J.
    Jun 11, 2017 at 15:58
  • \$\begingroup\$ Can you show us the rest of how you've set this up - your hierarchy of objects, the inspector for the object the animation is playing on, and (if applicable) the animation controller graph if you're using an Animator component rather than an Animation component? \$\endgroup\$
    – DMGregory
    Jun 11, 2017 at 16:44
  • \$\begingroup\$ animatOR and animatION are two different things. The code line you show plays an animatOR state from the corresponding animator component? You have more than one animator? \$\endgroup\$
    – Nikaas
    Jun 11, 2017 at 16:57
  • \$\begingroup\$ @DMGregory, all the child objects are shown in the animation window. the parent is an empty game object. \$\endgroup\$
    – Joel J.
    Jun 11, 2017 at 17:06

1 Answer 1

0
\$\begingroup\$

I must admit, I'm somewhat of a neophyte when it comes to unity. But the solution that worked for me is switching the animator components for the parent and child objects on when I need them the animations to play and off when I didn't. It's like unity can only work with one animator component at a time...but hey whatever works right?

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .