Search Unity

Question Animator with multiple layers. Stop and restart an animation from one of these layers.

Discussion in 'Animation' started by GMBLO, Jan 10, 2023.

  1. GMBLO

    GMBLO

    Joined:
    Dec 30, 2020
    Posts:
    5
    I have an animator with two layers. How can I stop and restart the animation in a layer.

    All my attempts have been unsuccessful....
     
  2. GMBLO

    GMBLO

    Joined:
    Dec 30, 2020
    Posts:
    5
    I have found a solution

    • goes to parameters in animator
    • create a new float parameter
    • set this to 1.0
    • click on the "State"
    • set under "Speed" the create parameter
    • In C# write animator.SetFloat("speedMultiplier", 0f);
    • "speed Muliplier" is the name of the parameter and can be freely selected
    • and the animation will stop
    • to move the object with C# you have to turn off the animator
    • This works like this: animator.enabled = false;