Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Join us on March 30, 2023, between 5 am & 1 pm EST, in the Performance Profiling Dev Blitz Day 2023 - Q&A forum and Discord where you can connect with our teams behind the Memory and CPU Profilers.
    Dismiss Notice

Resolved Animator.Play() using normalizedTime not working with sub layers ?

Discussion in 'Animation' started by edin97, Mar 18, 2023.

  1. edin97

    edin97

    Joined:
    Aug 9, 2021
    Posts:
    49
    Hello,

    It's a multiplayer game, if a player reconnects while an animation is playing, I am sending him the current animation normalizedTime so he can keep up with the others. Using an Action/event, 2 animators are triggered.

    1st animator is an environment one :
    Code (CSharp):
    1.         _animator.Play("Base Layer.EndGameTriggered", 0, animStartTime);
    Works perfectly. uses Base Layer.

    This is the "_animator" Animator Controller :
    upload_2023-3-18_13-27-37.png

    And the "Transitions" :
    upload_2023-3-18_13-36-20.png

    2nd animator is on the players :
    Code (CSharp):
    1.         PlayerAnimator.Play("EndGame.DeathFromStrike", 0, animStartTime);
    Not working. animation never starts even if animStartTime = 0. Animator stays in the "IDLE" state.

    This is the "PlayerAnimator" Animator Controller : upload_2023-3-18_13-26-29.png

    And the "Transitions" (which are not really used anymore since I'm using Play(...)) :
    upload_2023-3-18_13-35-48.png

    upload_2023-3-18_13-34-21.png
    (I tried removing the transition to IDLE, not working)

    Base Layer IS a blend tree.

    What am I doing wrong ? is the Play() with normalizedTime never working on sub-layers ? Script with Action/event should be good, everything worked when using animator.SetTrigger("..."); (but I can't set the time with settrigger.)

    Thanks in advance !

    using Unity 2020.3.15f2
     
  2. edin97

    edin97

    Joined:
    Aug 9, 2021
    Posts:
    49
    I'm dumb, I just copy/pasted the doc example, which has the layer = 0 without explaining what it does in the coms, I just changed 0 to -1
    Code (CSharp):
    1. PlayerAnimator.Play("EndGame.DeathFromStrike", -1, animStartTime);
    Or I could have put "6" instead of "-1" in my case, but whatever. It works now !