Question by 
               alorzadeh · Dec 18, 2016 at 12:26 AM · 
                animationchild object  
              
 
              Playing Child object animation
Hi,
I'm having trouble accessing Child object animation. I attached an animation to one of child objects, I want the animation to play when player health goes down. Can you please help me figure out what's wrong? Here is my script:
using System.Collections; using System.Collections.Generic; using UnityEngine;
      public class PlayerManager : MonoBehaviour {
     public GameObject player;
 private Animator playerAnimator;
 void Start () {
     Instantiate (player, new Vector3 (0,0,0), Quaternion.identity);
     playerAnimator = GetComponentInChildren<Animator>();
 }
 void Update () {
     if (SpawnNucleosome.health < 4) {
         playerAnimator.SetTrigger("BeadCrack");
     } else if (SpawnNucleosome.health < 3) {
         playerAnimator.SetTrigger("BeadCrack2");
     } else if (SpawnNucleosome.health < 2) {
         playerAnimator.SetTrigger("BeadCrack3");
     }
 }
 
               }
               Comment
              
 
               
              Answer by OmerPasa3328 · Aug 06, 2021 at 03:13 PM
is it playing or what is animation doing mate and why did you put animator in child you can use it in parent?
I think if you animate from parent that might work?
Your answer