Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Question Animator layer weights reset if set too early?

Discussion in 'Animation' started by lcompton, Nov 25, 2023.

  1. lcompton


    Mar 31, 2018
    I have an NPC that carries a tool. The NPC is spawned into the scene and in the Start() method of a tool mgmt script, the tool is equipped. Among other things, equipping the tool includes setting the animator layer weight for the tool's layer to 1.

    Occasionally, the animations on the tool's layer are not executed. What I found is that the tool layer weight is being set back to 0 sometime after I set it to 1. It doesn't happen every time, but it does happen frequently.

    I implemented a workaround that just defers the tool equip for a short while with a coroutine, rather than doing it immediately in the Start() method.

    Has anyone experienced this problem? Is it necessary to defer setting animator layer weights?