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");
}
}
}