0
\$\begingroup\$

So using what I found on my other question, I wrote this code:

private void Die()
    {
        Animator.updateMode = AnimatorUpdateMode.UnscaledTime;
        EllaAnimator.updateMode = AnimatorUpdateMode.UnscaledTime;
        for (int i = 0; i < Mathf.CeilToInt(LastRemainedHearts / 2f); i++)
        {
            ParentMiddleBelt.transform.GetChild(i).GetChild(1).GetComponent<Animator>().updateMode = AnimatorUpdateMode.UnscaledTime;
            ParentMiddleBelt.transform.GetChild(i).GetChild(1).GetComponent<Animator>().enabled = true;
        }
        Time.timeScale = 0;
        EllaAnimator.SetInteger("RunTo", 8);
        EllaAnimator.SetInteger("PushToward", 5);
        EllaAnimator.SetBool("Death", true);
    }

as you can see, there are three animators which I'm trying to change their update mode:

  • Animator: the animator on this object
  • EllaAnimator: the player's animator
  • ParentMiddleBelt.transform.GetChild(i).GetChild(1).GetComponent(): the animator attached to "health bullet"s (see the pictures below)

Animator and EllaAnimator run perfectly fine but for some reason, the third one doesn't.

I used print() and inspector to see if the UpdateMode is being changed or not and as it turned out, it does change. So my problem is that regarding UpdateMode being set to unscaled time, why it still doesn't play?

side note: ParentMiddleBelt is an empty game object that stores clones of belt(middle) prefab

enter image description here

enter image description here

\$\endgroup\$

1 Answer 1

0
\$\begingroup\$

I was trying to mess around a bit and found the answer:

The ParentMiddleBelt.transform.GetChild(i).GetChild(1).GetComponent<Animator>().enabled = true; line should have come before ParentMiddleBelt.transform.GetChild(i).GetChild(1).GetComponent<Animator>().updateMode = AnimatorUpdateMode.UnscaledTime;

It seems changing properties of a disabled component have no effect

\$\endgroup\$
1
  • \$\begingroup\$ Don't forget to mark this answer as accepted if it worked for you. \$\endgroup\$
    – DMGregory
    Mar 27, 2022 at 18:04

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .