- Home /
Accessing a parent's other children
I have a Player GameObject which has many children. One of them is an Animator which I am trying to access from a script attached to another child (of the Player GameObject).
private Animator animator;
void Awake(){
animator = transform.parent.FindChild ("Animator");
}
Basically accessing the parent first then it's child Animator (named "Animator").
The error being thrown is - Cannot implicitly convert type 'UnityEngine.Transform' to 'UnityEngine.Animator' .
What seems to be the problem?
Answer by Jeff-Kesselman · Nov 10, 2014 at 06:51 PM
FindChild is for finding child game objects, not components.
You want to use GetComponentsInChildren
Your answer
Follow this Question
Related Questions
Objects dissapearing and then appearing 0 Answers
Can I stop a lerp completely when it gets to 20% of its original value? 3 Answers
Changing the size of a BoxCollider2D at runtime. 1 Answer
How does a game engine work and how can you use that to make one? 1 Answer
Help! how to convert input.GetAxis to Accelerometer 0 Answers