Search Unity

How to keep object state after timeline completes?

Discussion in 'Timeline' started by BrainAndBrain, Nov 16, 2017.

  1. BrainAndBrain

    BrainAndBrain

    Joined:
    Nov 27, 2014
    Posts:
    115
    I'm using Timeline/Cinemachine to animate cameras and objects in a small cutscene. When the scene is complete (e.g. the Timeline has reached its end point), all of the objects have their values reset to their state before the Timeline was played.

    I would like the objects to maintain their new values after the Timeline completes. Is there a way to do this?

    Thanks!
     
  2. joebain

    joebain

    Joined:
    Oct 24, 2014
    Posts:
    49
    I found if you set the Wrap Mode on the Playable Director component to "Hold" it seems to preserve the changes that the timeline makes after it finishes.
     
    francesco_unity944 likes this.
  3. seant_unity

    seant_unity

    Unity Technologies

    Joined:
    Aug 25, 2015
    Posts:
    1,516
    It varies depending on the track you are using.
    - Activation tracks have an option on the track for what state the object should be in when the timeline ends.
    - Animation tracks leave their objects in their current state, but it may appear the values are being reset if you have a animator controller attached. The control of the object passes back from timeline to the controller.

    The 'Hold' option does work as well, but be aware that it does that by keeping the timeline running, so you won't be able to change any values it is 'holding'.
     
  4. joebain

    joebain

    Joined:
    Oct 24, 2014
    Posts:
    49
    Ah, that's helpful thanks. I didn't realise you could have a playable director without an animator controller though! I will try that as I will want to change the values / states at some point.
     
  5. joebain

    joebain

    Joined:
    Oct 24, 2014
    Posts:
    49
    Ok, so I just tested that, and maybe I was being a bit stupid, but you have to have an enabled Animator on your object if you want to use an animation track in the timeline. Or is there another way to use animation tracks without an Animator component?
     
  6. seant_unity

    seant_unity

    Unity Technologies

    Joined:
    Aug 25, 2015
    Posts:
    1,516
    Animation tracks require an enabled Animator component. The animator is what applies the result of the animation track to the game object.
     
  7. joebain

    joebain

    Joined:
    Oct 24, 2014
    Posts:
    49
    Ah ok. Seems like I need to look at a custom script to save transforms etc after the timeline animation has finished. Thanks.
     
  8. seant_unity

    seant_unity

    Unity Technologies

    Joined:
    Aug 25, 2015
    Posts:
    1,516
    You shouldn't have to - the timeline should leave it alone if there is no animator controller. If there is, the controller should pick up where you left off, if you are using root motion.
     
  9. joebain

    joebain

    Joined:
    Oct 24, 2014
    Posts:
    49
    My particular set up I have a single animation I want to play on a static object, like a door opening. So I want the timeline to play that animation and leave the object in the state of the last frame of the animation. I'm only using the animator controller because the timeline requires one, not because I have any complex animations or animation graph. So the animator controller is resetting the transform, but I can't remove it because otherwise the timeline can't play the animation at all. Or am I missing something?
     
  10. fherbst

    fherbst

    Joined:
    Jun 24, 2012
    Posts:
    802
    Just to clarify @joebain : the Animator is the component, while the AnimatorController is the controller assigned to that component. Timeline only requires the Animator, not the Controller:

    upload_2019-7-8_12-31-1.png

    Note that this makes animating objects way harder, because now "of course" the Animation window won't show your clips (as no Animator Controller is assigned with any clips). So you'll have to re-assign the Controller, animate, then remove the Controller again...
     
  11. DGordon

    DGordon

    Joined:
    Dec 8, 2013
    Posts:
    649
    Any chance you guys can build in a way to flag a controller as "timeline only" (or something more generic), so we dont have to bounce them in and out like above?
     
    d1favero likes this.
  12. DarkGate

    DarkGate

    Joined:
    Jan 26, 2016
    Posts:
    33
    I am also running into the same issue. I want to use Timeline to perform a cutscene, and I want to persist the last state of that cutscene (it current just snaps back). It would be nice to add an option into Timeline that allow users to persist the states.