Search Unity

Keep timeline playing infinitely

Discussion in 'Timeline' started by vambier, Jun 27, 2022.

  1. vambier

    vambier

    Joined:
    Oct 1, 2012
    Posts:
    102
    I have created a cutscene which has a begin, a middle section which can be looped and an end.
    I created the intro, now when this is ended I want to keep the last state of the intro running while a dialog is playing on top of this which the player is interacting with. When the dialog is done the end animation wil be played.
     
  2. akent99

    akent99

    Joined:
    Jan 14, 2018
    Posts:
    588
    Do you mean you want to "pause" the timeline while the dialog is being read then "play" it again when the dialog is closed? Or do you want to loop the middle timeline while it is open?
     
  3. vambier

    vambier

    Joined:
    Oct 1, 2012
    Posts:
    102
    I want to loop the middle part
     
  4. akent99

    akent99

    Joined:
    Jan 14, 2018
    Posts:
    588
    Someone might have a better solution, but I would consider a "signal" near the end that restarts the current timeline if the dialog is closed (does a "seek") otherwise starts the next "end" timeline. (I recall reading people saying there is no event for when the end of a timeline is reached - so you need to add your own "signal" on the last frame yourself. Signals were added in 2019.1 I believe.)
     
  5. vambier

    vambier

    Joined:
    Oct 1, 2012
    Posts:
    102
    Ok, this sounds like it could work. Maybe this would explain better what I want :

    upload_2022-6-28_22-44-46.png
    So at the start of the timeline a couple of animations start and the last state of these will keep looping, for example a lamp turns on and keeps burning after turning on. When these intro animations are done the dialogue starts, first the npc says something so the text needs to be shown, at the same time the talking animation for the npc needs to start, this animation needs to stay active as long as the text is shown, this wil be until the player presses a button. After this the text and talk animation for the player wil be shown etc. When all the talking is done a couple of animations wil be shown to exit the scene.
     
  6. akent99

    akent99

    Joined:
    Jan 14, 2018
    Posts:
    588
    Unfortunately I don't think you can mix timeline animations with animator controller animations (e.g. smoothly blend between them). I was wondering if the alternative is to define a state machine for the animation clips (not use Timeline) and just trigger state changes. Then you get looping for free. But I have not heard of much success mixing timeline animations and animator controller animations (hmmm, there was some code someone shared about a custom approach for doing it now that I recall on the forums). Since I am doing more like filmmaking, timeline is what I am after and all I use. Good luck!
     
  7. vambier

    vambier

    Joined:
    Oct 1, 2012
    Posts:
    102
    Would it be doable with nested timelines?
     
  8. akent99

    akent99

    Joined:
    Jan 14, 2018
    Posts:
    588
    I don't think so. My understanding is Animation Tracks in Timeline and Animator Controllers don't talk to each other - one or the other wins. There is no code to "blend/mix" the values from the other one.