- Home /
How to Control animator of child objects
I have a parent with an object as a child. I have also referenced the child in the parent as
public GameObject guy;
The child game object has an Animator controller attached with "Idle" and "Jump" animations. I have a transition that goes from Idle to jump with a bool condition of "jump - true".
On the parent object I would like to trigger this condition. I have tried
guy.anim.SetBool("Transform", true);
I keep getting "Type UnityEngine.GameObject' does not contain a definition for
anim' and no extension method anim' of type
UnityEngine.GameObject' could be found"
I have
private Animator anim;
in the scripts of both the parent and child objects... Can anyone point me in the right direction please?
Answer by Tehnique · Mar 23, 2015 at 09:02 AM
Well, the parent does not see the components on the child, you have to get them by hand.
Try
guyAnim = guy.GetComponent<Animator>();
and then set the bool on the "anim":
guyAnim.SetBool("jump", true);
Your answer
![](https://koobas.hobune.stream/wayback/20220613190927im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Mecanim animation 1 Answer
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
How can I get the legnth of an animation? (Mechanim Animator/C#) 2 Answers
Animations not Transitioning 0 Answers