Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

How can I play a animation only once?

Discussion in 'Animation' started by Kertaix, Aug 9, 2022.

  1. Kertaix

    Kertaix

    Joined:
    Jul 19, 2022
    Posts:
    33
    Hi


    I have a animation for a attack for my player. Now I want to play this animation when I press a mousebutton.

    Is there a way to get it so that it can go from any state in to this animation, play it once and then go back to the previous state?


    (The important part is to get it to play only once and returne to the previous. I know how to get from any state into the attack animation)


    thanks in advance
     
  2. sstrong

    sstrong

    Joined:
    Oct 16, 2013
    Posts:
    2,229
    upload_2022-8-10_17-58-1.png

    Did you make sure Loop Time is NOT checked in the animation?
     
    Flying_Banana likes this.
  3. Kertaix

    Kertaix

    Joined:
    Jul 19, 2022
    Posts:
    33
    Yes

    But then it just gets stuck at the last frame and doesnt go back to the previous animation. But I've now done it with a bool which is true for the time of the animation playing once. That probably takes more effort than needed but it works.

    Thanks anyways
     
  4. sstrong

    sstrong

    Joined:
    Oct 16, 2013
    Posts:
    2,229
    Ok, you prob need something like this with a trigger

    upload_2022-8-10_22-26-45.png
     
    Kertaix likes this.