Search Unity

Looping recorded animations indefinitely in the new Timeline.

Discussion in 'Timeline' started by hexedecimal, Jul 17, 2017.

  1. hexedecimal

    hexedecimal

    Joined:
    Jul 17, 2017
    Posts:
    2
    I'm having trouble looping a recorded animation with the new timeline feature. Here is what I've done and where I get stuck:
    • Created game object (cylinder in this example)
    • Created timeline asset for cylinder
    • Turned on timeline record mode and made a simple 2 keyframe animation
    • Turn recorded keyframes into animation clip
    • Animation plays fine
    • Set Post-extrapolate to "Loop" in clip inspector
    • Stretch clip in timeline, but it never loops, it defaults to "Hold"
    I want the animation to loop for the entire duration of the game, over and over again as long as it's playing. What's the best way to achieve this? -- preferably avoiding C#, I'd like everything to be accessible from the GUI if possible.
     
  2. DGordon

    DGordon

    Joined:
    Dec 8, 2013
    Posts:
    649
    I would also like to know if this is possible. So far we have been assuming looping only works when we use an Animation clip ... which is very frustrating, since it forces our artist to use two different methods depending on the use-case and increases the chance of problems occurring.

    [Edit -- Sorry, I think I misread the above. I was hoping for the recorded animation to be loopable without requiring it be turned into an animation clip or copy/paste frames.]
     
    Last edited: Jul 19, 2017
  3. julienb

    julienb

    Unity Technologies

    Joined:
    Sep 9, 2016
    Posts:
    177
    Your timeline duration is based on clips (the blue line in the timeline editor). Since your timeline ends when the clip ends, it cannot loop. In this case, you have two choices.

    a) Change the PlayableDirector's wrap mode to Loop.



    b) Change the timeline's duration
    Right-click in the timeline ruler, then choose Duration Mode -> Fixed Length.

    You can then drag the blue line in the timeline ruler to expand the timeline duration. If your clip's Animation Extrapolation is set to Loop, it will then loop for the whole timeline duration.
     
    poiuminaj, fontinixxl, art092 and 3 others like this.
  4. hexedecimal

    hexedecimal

    Joined:
    Jul 17, 2017
    Posts:
    2
    Game changer! @julienb thank you so much. A bit different to how I'm used to doing it in After Effects. Works like a charm.
     
    P_Jong and julienb like this.
  5. Misscelan

    Misscelan

    Joined:
    Mar 8, 2013
    Posts:
    176
    Is it possible to loop the clip withouth looping the whole project?
    I have more tracks in the timeline (that don't have to loop) and none of the above proposed solutions works in my case.

    Thanks!
     
  6. seant_unity

    seant_unity

    Unity Technologies

    Joined:
    Aug 25, 2015
    Posts:
    1,516
    To loop a recording, you should be able to convert it to a clip, then set the post extrapolate option to loop. It should then loop for the duration of the timeline.
     
    Foge likes this.
  7. Misscelan

    Misscelan

    Joined:
    Mar 8, 2013
    Posts:
    176
    mm that's what I thought.
    But as the creator of this post mentioned, it doesn't work that way.
    Any ideas why this wouldn't work?

    Thanks!
     
  8. seant_unity

    seant_unity

    Unity Technologies

    Joined:
    Aug 25, 2015
    Posts:
    1,516
    You can either not stretch the clip, and use a fixed length for the timeline (right click on the end marker). Extrapolate is what happens between clips, not what happens when stretched.

    Or you can click on the Animation Clip in the timeline clip inspector to bring up the inspector for the animation clip itself, and enable looping on the recorded animation clip. When you stretch the clip it uses the properties of the animation clip being played, and recorded animation clips don't enable looping by default. Alternately you can find the animation clip as a sub-asset of the timeline.

    Hope that helps
     
  9. Diesign

    Diesign

    Joined:
    May 15, 2016
    Posts:
    16
    @seant_unity Thanks for your writeups

    Is it correct to interpret this thread to mean that Timeline does not currently support an infinite loop and that the workaround is a very long duration timeline containing a looping clip?

    For example if I wanted to have a timeline that contains an infinitely looping idle animation I would have to implement that idle with an animation controller and make that controller play nicely with the Timeline?
     
  10. seant_unity

    seant_unity

    Unity Technologies

    Joined:
    Aug 25, 2015
    Posts:
    1,516
    Yes, at least in 2018.2 and prior. With the changes to animation tracks in 2018.3, we are looking at ways to make this exact use case work (i.e. loop a timeline and have the animation track offsets update automatically on each loop). Not sure if that will make it in 2018.3 or 2019.1 yet.
     
  11. Diesign

    Diesign

    Joined:
    May 15, 2016
    Posts:
    16
    Thanks @seant_unity

    The standard looping tools seem to play nicely with timeline so its more of a minor inconvenience than a major need for me at least.
     
  12. mk1316a

    mk1316a

    Joined:
    Dec 13, 2020
    Posts:
    1
    Thanks this, playable director trick works