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 Thursday, June 8, for a Q&A with Unity's Content Pipeline group here on the forum, and on the Unity Discord, and discuss topics around Content Build, Import Workflows, Asset Database, and Addressables!
    Dismiss Notice

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;