- Home /
GetComponetInChildren for 2+ animator
hi, i'm making an fps and now i've just finished the animation for the aim. the script is placed in the "firstpersonchartercontroller" and it has 1 child that has 1 child that has the Gun, and the gun has the animator on it. everything work fine but now iwant to utilize another animator that i have putted in the frist child of the controller. but anim = GetComponentInChildren take only 1 animator of the 2.
how i can utilize 2 animator at onece (or utilize animation of an object in the animator of another)? thanks
Answer by HarrisonJH · Jan 11, 2015 at 12:57 PM
Try this
declare anim
as an array: Animator[] anim;
use GetComponentsInChildren instead
do things to anim
in a for loop:
foreach (Animator a in anim)
{
do things
}
Answer by code_warrior · Jan 11, 2015 at 11:45 AM
Hi Pumpkinotto,
you could try using the following (C#):
Animator[] animArray;
animArray = GetComponentsInChildren<Animator>();
foreach (Animator anim in animArray) {
//Do something cool with anim
}
The difference between GetComponentsInChildren and GetComponentInChildren is that it returns multiple objects. code_warrior
Your answer
Follow this Question
Related Questions
Controlling value of blend parameter via script 0 Answers
Check If Animator Animation Has Finished 1 Answer
How to blend model's position into Animator Controller 0 Answers
Can't Set Animator Boolean Parameter C# 1 Answer
Root motion handled by script. How to still use root motion with disabled navmesh agent? 0 Answers