How to start animation of child
I have a parent object (a bird with a basket) which comes into the game after you push a button. A tiny guy in the basket is the child object of the bird and the basket. It has to appear when you click the basket. I have the animation for the little guy showing himself but don't know the code to get him to appear. For the bird flying into the game with the basket i use
anim.SetTrigger("'BirdFlies");
But I probably need to attach someting more to this code, so it can access the child object. Does anyone know what I have to do?
Thank you in advance.
Cheers,
Jonah
anim seems to be the animator of the bird. doesn't the guy also have one? it usually doesn't matter where in the hierarchy he is. you could probably have animGuy as a serialized field on the same script, assign it in the inspector and call animations the same way you call on the bird.
but if they're both animated as one object, that's going to be more complicated
Answer by jonahsrocket · Nov 23, 2016 at 09:43 AM
Hi everybody,
thank you for your answers. I tried to figure out the GetComponentsInChildren code (because I think that would solve the problem) but it didn't work. That means, I just don't get it.
I now solved my problem by changing the animations itself. It's a bit of an easy escape (avoiding coding) but it solved my problem. So I am happy ;)
Thank you again for answering!
Cheers,
Jonah
Your answer
Follow this Question
Related Questions
how to add prefab to gameobject? 2 Answers
Child always on parent top to get the number of dice 0 Answers
Lock rotation of child's specific axis? 0 Answers
Detecting mouse click on specific child game object UnityScript 1 Answer
Triggering animations in multiple parent objects (buttons) in a User Interface. 1 Answer