public Animator ClosestAnimator() { if (anim != null) { return(anim); } //check to see if any children have animators. return in you find one for (int i = 0; i < transform.childCount; i++) { Transform child = transform.GetChild(i); Animator a = child.GetComponent <Animator> (); if (a != null) { return(a); } } //check to see if any children have animation transforms, and call closest animator on them as well. for (int i = 0; i < transform.childCount; i++) { Transform child = transform.GetChild(i); AnimationTransform at = child.GetComponent <AnimationTransform> (); if (at != null) { Animator a = at.ClosestAnimator(); if (a != null) { return(a); } } } return(null); }
void Awake() { rootAnimationTransform = GetComponent <AnimationTransform> (); root = rootAnimationTransform.ClosestAnimator(); foreach (EquipmentAnimatorMapping anim in animators) { anim.current = EquipmentAnimationControllerName.NOT_SET; } }
// Use this for initialization void Start() { animationTransform = GetComponent <AnimationTransform> (); rootBody = animationTransform.ClosestAnimator(); animationTransform.OnAnimationEvent += AnimationEventHappened; //animationTransform.SetTrigger ("walkDown"); //rootBody.speed = 0f; }
void Awake() { animationTransform = GetComponent <AnimationTransform> (); infoHook = animationTransform.ClosestAnimator(); currentPath = new List <string> (); RoundPositionToNearestWhole(); animationTransform.OnAnimationEvent += AnimationEventHappened; }