Search Unity

Help Wanted Playing several animations with one animator controller

Discussion in 'Animation' started by Tixal, Oct 12, 2021.

  1. Tixal

    Tixal

    Joined:
    Mar 9, 2017
    Posts:
    12
    Hi friends, I have to make a simple title animation which is built by three separate animations, the first two animations are arranging some images and they play only once, finally the third animation waits until the first two are completed and plays looped animation of a flame.
    I know how to do this with three separate animator controllers, however my client wants them to be placed inside a single animator controller. I tried using different layers and changing their weight values, but the animations never played the way they were recorded, some of them didn't play at all, others were playing with swapped sprites from the rest animations.
    For the frame by frame animation of the flame I use Unity Sprite Atlas component to optimize the frames and the animations are displayed by UI Image component. The other animations are simple key frame transform changes.
    I tried almost everything in google, but nothing seems to be working, If you have any ideas about this problem I'll be very thankful :)
     
  2. Unrighteouss

    Unrighteouss

    Joined:
    Apr 24, 2018
    Posts:
    244
    Hey,

    This should be incredibly simple.

    Just set up your animator controller with transitions to each animation in order. Make sure that "Has Exit Time" is checked for both transitions and set it to 1.

    Controller.JPG

    For the looping animation, make sure that "Loop Time" is checked in that animation's inspector window.

    Loop.JPG
     
    Tixal likes this.
  3. Tixal

    Tixal

    Joined:
    Mar 9, 2017
    Posts:
    12
    Thank you for the reply. Yes, it should be very simple, unfortunately it is not, this sequence is not working because when an animation reaches its end Unity is resetting it to the beginning, so animation 1 and animation 2 will both end with their first frames, not with their last frames, If I have to make it work with some code I'll make it work perfect and actually without using any transitions, layers and so on, unfortunately the client doesn't want to use any code :(
     
  4. Unrighteouss

    Unrighteouss

    Joined:
    Apr 24, 2018
    Posts:
    244
    Okay, yeah I see the issue now.

    The only thing I can think of to solve this without code/layers is to add the end frame of Animation1 to the start of Animation2, and then add then add the end frames of Animation1/2 to start of Animation 3. This should make it fairly seamless.
     
    Tixal likes this.
  5. Tixal

    Tixal

    Joined:
    Mar 9, 2017
    Posts:
    12
    That makes perfect sense, thank you for the help, unfortunately the client decided to create animations on his own... ¯\_(ツ)_/¯
     
  6. Unrighteouss

    Unrighteouss

    Joined:
    Apr 24, 2018
    Posts:
    244
    You have the .anim files right? You can't copy frames from one to another in Unity? If the animations were made using Unity (which they should be if they're transform/sprite animations), then you should be able to copy frames from one animation to another using the animation window.
     
    Tixal likes this.
  7. Tixal

    Tixal

    Joined:
    Mar 9, 2017
    Posts:
    12
    Yes, that's exactly what I'm going to do next time if I have such a bizarre request from a client :)
     
unityunity