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. Dismiss Notice

Running animation in specific time

Discussion in '2D' started by therocketman2018, Jul 31, 2020.

  1. therocketman2018

    therocketman2018

    Joined:
    Apr 25, 2019
    Posts:
    46
    So i am trying to start my animation from a specific time/frame, but the animation just keeps going without changing the frame.

    anim.speed = 0; works, and it stops the animation from running.
    anim.Rebind(); works and it starts the animation from the beginning.
    BUT i cant make the animation run from specific frame or specific time.

    Code (CSharp):
    1. public GameObject dogGirl;
    2.  
    3. void Start()
    4. {
    5. anim = dogGirl.gameObject.GetComponent<Animator>();
    6. }
    7.  
    8. void Update()
    9. {
    10. anim.Play("dogGirlMoving", 0, 0.5f); //This does not work.
    11. }
     
    Last edited: Jul 31, 2020
  2. therocketman2018

    therocketman2018

    Joined:
    Apr 25, 2019
    Posts:
    46
    1 view. I can see that people get more views by making the title "HElp mE" :D
     
  3. therocketman2018

    therocketman2018

    Joined:
    Apr 25, 2019
    Posts:
    46
    Problem solved. It needed the BaseLayer name:
    anim.Play("BaseLayerMoving.dogGirlMoving", -1, 0.77f);