Search Unity

  1. Get all the Unite Berlin 2018 news on the blog.
    Dismiss Notice
  2. Unity 2018.2 has arrived! Read about it here.
    Dismiss Notice
  3. Improve your Unity skills with a certified instructor in a private, interactive classroom. Learn more.
    Dismiss Notice
  4. ARCore is out of developer preview! Read about it here.
    Dismiss Notice
  5. Magic Leap’s Lumin SDK Technical Preview for Unity lets you get started creating content for Magic Leap One™. Find more information on our blog!
    Dismiss Notice
  6. Want to see the most recent patch releases? Take a peek at the patch release page.
    Dismiss Notice

Timeline - Available in Unity 2017.1

Discussion in 'Timeline' started by mikew_unity, Feb 7, 2017.

  1. Danirey

    Danirey

    Joined:
    Apr 3, 2013
    Posts:
    495
    First i would set the scene objects or whatever you want to animate inside the timeline with default state, be position, or some values in a script, but unchecking the preview button on the top left corner of the timeline window. Once you hafe the default state for the scene objects, you can start edditing the timeline. This is some kind of standard process on every timeline based workflow.
     
  2. julienb

    julienb

    Unity Technologies

    Joined:
    Sep 9, 2016
    Posts:
    91
    Here's how you can do it at runtime:
    Code (CSharp):
    1. using UnityEngine;
    2. using UnityEngine.Playables;
    3. using UnityEngine.Timeline;
    4.  
    5. public class TimelineController : MonoBehaviour
    6. {
    7.     public PlayableDirector masterDirector;
    8.     public PlayableDirector slaveDirector;
    9.  
    10.     void Start ()
    11.     {
    12.         if (masterDirector == null || slaveDirector == null)
    13.             return;
    14.    
    15.         //create new timeline asset on the master
    16.         var masterTimelineAsset = ScriptableObject.CreateInstance<TimelineAsset>();
    17.         masterDirector.playableAsset = masterTimelineAsset;
    18.  
    19.         //create control track and clip
    20.         var controlTrack = masterTimelineAsset.CreateTrack<ControlTrack>(null, "ControlTrack");
    21.         var clip = controlTrack.CreateDefaultClip();
    22.            
    23.         //set master clip duration based on the slave's duration
    24.         clip.start = 0;
    25.         clip.duration = slaveDirector.playableAsset.duration;
    26.    
    27.         // this is the tricky part. We will grab the control playable asset from the clip.
    28.         // A ControlPlayableAsset needs an exposed reference set to the object that will be controlled.
    29.         // In order to set the exposed reference to the right value, we need to use the PlayableDirector and the exposedReference's exposedName.
    30.         // This will bind our target game object (the slave director) to the master director's ControlPlayableAsset.
    31.         var controlPlayable = clip.asset as ControlPlayableAsset;
    32.         masterDirector.SetReferenceValue(controlPlayable.sourceGameObject.exposedName, slaveDirector.gameObject);
    33.    
    34.         //Awesome, let's see if this works!
    35.         masterDirector.Play();
    36.     }
    37. }
    38.  
    This should do what you need. The less obvious part is how to set the exposed reference on the ControlPlayableAsset. See this thread.
     
    rakkarage and Carwashh like this.
  3. Carwashh

    Carwashh

    Joined:
    Jul 28, 2012
    Posts:
    281
    Thanks very much, I'll give it a go at work tomorrow.
     
  4. funyashow

    funyashow

    Joined:
    Nov 19, 2012
    Posts:
    1
    hi

    I try to delete timeline track.

    --------------------------------------------------------------------------------------------
    TimelineAsset _timeline = timeline;
    int count = _timeline.outputTrackCount;
    TrackAsset ta = _timeline.GetOutputTrack (count - 1); // this track is ControlTrack
    _timeline.DeleteTrack (ta);
    --------------------------------------------------------------------------------------------

    I succeed in timeline track elimination.
    The following error goes out.

    --------------------------------------------------------------------------------------------
    MissingReferenceException: The object of type 'ControlTrack' has been destroyed but you are still trying to access it.
    Your script should either check if it is null or you should not destroy the object.
    --------------------------------------------------------------------------------------------

    Please tell me how it can be settled.
     
    Last edited: Aug 31, 2017
  5. Teh_Lemon

    Teh_Lemon

    Joined:
    May 12, 2015
    Posts:
    17
    Sorry if I've missed something. How do I set the frame without playing the Timeline?

    I have a Timeline that animates Material properties on a trigger hit. The problem is that Material properties don't revert to defaults at the end of the scene play.
    I tried calling playableDirector.time = 0 in my Start() but while that moves the scrubber head in the Timeline editor window, it doesn't actually change any of the objects.
     
  6. Chris_Payne_QS

    Chris_Payne_QS

    Joined:
    Jul 16, 2016
    Posts:
    40
    I've got a disabled GameObject which is turned on briefly using an Animation Track. This all works perfectly while scrubbing the timeline in the editor...but in Play mode, when the timeline completes it turns the GameObject (which was off at the end of the sequence) back on. How do I make it stay off?
     
  7. Carwashh

    Carwashh

    Joined:
    Jul 28, 2012
    Posts:
    281
    Click on the activation track -> inspector -> change the 'Post-playback state'
     
    Chris_Payne_QS likes this.
  8. Chris_Payne_QS

    Chris_Payne_QS

    Joined:
    Jul 16, 2016
    Posts:
    40
    THANK YOU! :)
     
  9. pocketpair

    pocketpair

    Joined:
    Jul 7, 2015
    Posts:
    2
  10. julienb

    julienb

    Unity Technologies

    Joined:
    Sep 9, 2016
    Posts:
    91
    You cannot get the curves at runtime. This is something we get asked a lot; we will try to add a way to get curves in a future Timeline update.

    Happy to hear you adopted Timeline =)
     
  11. rneron1

    rneron1

    Joined:
    Jun 16, 2017
    Posts:
    9
    Hello! Do you plan to make Playmode Timeline Realtime recording? See image example :)

    And in a second question, it can be really useful to have a 3D path with handles to manage animation in Timeline.
    It can be a solid feature for Unity! See example on my second image :) Playmode Timeline Realtime recording.jpg 3D_Path_workspace.jpg
     
    Rodolfo-Rubens likes this.
  12. JakubSmaga

    JakubSmaga

    Joined:
    Aug 5, 2015
    Posts:
    382
  13. rneron1

    rneron1

    Joined:
    Jun 16, 2017
    Posts:
    9
    JakubSmaga likes this.
  14. QuestionsBrown

    QuestionsBrown

    Joined:
    Aug 14, 2017
    Posts:
    4
    Does this support spawning objects at specific times using instantiate????
     
  15. QuestionsBrown

    QuestionsBrown

    Joined:
    Aug 14, 2017
    Posts:
    4
    I'm trying to find a way to spawn my AR environment/AR objects after floor detection has been tracking for lets say 5 to ten seconds
     
  16. Rodolfo-Rubens

    Rodolfo-Rubens

    Joined:
    Nov 17, 2012
    Posts:
    1,052
    Ah, yes, that would be great, I thought timeline had this from day 1...
     
  17. KenjiJU

    KenjiJU

    Joined:
    Dec 31, 2012
    Posts:
    5
    Does this work with blendshapes?
     
  18. elettrozero

    elettrozero

    Joined:
    Jun 19, 2016
    Posts:
    151
    Timeline play button (while not playing game) is not working.
    No errors in console (I updated Cinemachine to 2.1 RC).
     
  19. Jiraiyah

    Jiraiyah

    Joined:
    Mar 4, 2013
    Posts:
    175
    Hi
    If I want to reference Time line assembly inside a c# project (that will build a dll itself and this dll is not editor one) which version should i reference (there are 3 folders with dll files in it) ?
    there is an editor folder (obviously for those dll projects that has unityEditor reference) but there are two more one called Runtime and one called RuntimeEditor, which one of these two should i reference? (My project won't reference UnityEditor.dll)
    another question is when i would develop a project with UnityEditor in it, again should i choose the one under the editor folder or runtimeEditor one?

    sorry but the lack of information about the difference between these three files are a little troublesome.
     
  20. SpencerPDX

    SpencerPDX

    Joined:
    Jan 3, 2012
    Posts:
    128
    Hello! This seems like a real simple question, and I could have sworn I figured out how to do this when first fiddling with Timeline, but... How do I disable objects via an activation track? The only choice of clip I can add to an Activation track is "Active." But I thought there was a way to add an "Inactive." At the very start of this thread I see this:

    So I'd like to disable the object.

    I do see the track has "post-playback state" options that include inactive, but that's not what I'm looking for.

    Looking to add a key that deactivates the object from within the track.

    Any suggestions? Thanks!
     
  21. SpencerPDX

    SpencerPDX

    Joined:
    Jan 3, 2012
    Posts:
    128
    Aha, looking at it further, it seems that just adding an activation track but not adding an activation key (and deleting the activation key that gets added automatically) make the object go away. No obvious, to me at least, but elegantly simple.
     
  22. Carwashh

    Carwashh

    Joined:
    Jul 28, 2012
    Posts:
    281
    Click on the clip and you can set active/ inactive/ etc in the inspector
     
  23. cocos2der

    cocos2der

    Joined:
    Jul 1, 2014
    Posts:
    8
  24. musolo

    musolo

    Joined:
    Sep 12, 2014
    Posts:
    196
    Where can i download Timeline for my Unity 5.6.3p2 ?
    It was there earlier. What happened?
     
  25. jwvanderbeck

    jwvanderbeck

    Joined:
    Dec 4, 2014
    Posts:
    337
    It seems that int fields can't be keyed on Timeline. Is there a good reason for this? We have custom components with int fields that need to be animated in Timeline.
     
  26. GameDevCouple_I

    GameDevCouple_I

    Joined:
    Oct 5, 2013
    Posts:
    837
    Please make some documentation that clearly specifies the shortcomings of the current timeline system in regards to what has been promised in all of the videos.

    Currently there is no way to tell that this is a LLAPI, a HLAPI is coming, that playable and timeline are related (even the same thing, timeline plays playables).

    But above all, remove the videos that say timeline is effortless and time saving to integrate. Currently a wizard is needed just to get the things to generate properly.

    4 scripts plus an asset just to get something as simple as a basic playable in the scene?

    Please introduce some kind of QA step, and next time if you have missed a release deadline dont just shove it out the door because you said it would be ready then. Timeline is just a more convoluted animation window with support for animating more than 1 object currently , any performance savings are negated by the time it takes to integrate.
     
    alexzlov and Carwashh like this.
  27. JakubSmaga

    JakubSmaga

    Joined:
    Aug 5, 2015
    Posts:
    382
    Suggestion:

    -Add "Destroy" to post-playback state in the Activation Track.

    Also please consider multiple parameters support in the Timeline event system,
    many people hated that UI didn't supported that and still hate that.

    Thank you.

    Jacob
     
    Last edited: Nov 19, 2017
    Louren325 likes this.
  28. manran

    manran

    Joined:
    Jan 30, 2014
    Posts:
    34
    Hi guys i'm trying to import alembic animations files but i cannot find any tutorial on how to play it from the timeline editor for cinematic. Anyone have an idea please? Thanks
     
  29. manran

    manran

    Joined:
    Jan 30, 2014
    Posts:
    34
    Hello guys.
    Anyone know how to play alembic sequence from the timeline? Thanks
     
    Alverik likes this.
  30. prayshouse

    prayshouse

    Joined:
    Sep 11, 2017
    Posts:
    27
    Hello guys,
    After I add a timeline for my particle system, I found my particle system runs faster than before .
    Anyone knows why?
     
    Alverik likes this.
  31. awesomedata

    awesomedata

    Joined:
    Oct 8, 2014
    Posts:
    527
    Possibly this is due to pre-computation and the ability to add a random seed for particles now.

    To put it in Layman's terms -- in order to scrub back and forth in a timeline and have the particles in a system stay at the exact same positions/scales/etc, having this pre-computed only once with a random seed instead of running in realtime is very likely to save on performance.
     
    Alverik likes this.
  32. prayshouse

    prayshouse

    Joined:
    Sep 11, 2017
    Posts:
    27
    It seems the Start Delay of Particle System does not work after creating a Timeline for the particle system. Is that right?
     
  33. JakubSmaga

    JakubSmaga

    Joined:
    Aug 5, 2015
    Posts:
    382
    Is there any way to collapse all folders with a key/dropdown menu?
     
  34. nickgravelyn

    nickgravelyn

    Joined:
    Jan 22, 2009
    Posts:
    143
    Forgive me if this was already covered in the thread (it's quite long), but is this demo available anywhere? I was hoping to use Timelines to control doors and other "static" elements of my scene for gameplay but wasn't sure how to go about it. Even if there's no demo, if there's are some good docs and quick tips that'd be super helpful.
     
  35. GameDevCouple_I

    GameDevCouple_I

    Joined:
    Oct 5, 2013
    Posts:
    837
    Its been almost a year, and I would like some form of decent demo like this too!
     
    Alverik and awesomedata like this.
  36. Andy-Touch

    Andy-Touch

    A Moon Shaped Bool Unity Technologies

    Joined:
    May 5, 2014
    Posts:
    948
    GameDevCouple_I and rakkarage like this.
  37. GameDevCouple_I

    GameDevCouple_I

    Joined:
    Oct 5, 2013
    Posts:
    837
    theANMATOR2b likes this.
  38. Andy-Touch

    Andy-Touch

    A Moon Shaped Bool Unity Technologies

    Joined:
    May 5, 2014
    Posts:
    948
    GameDevCouple_I likes this.
  39. GameDevCouple_I

    GameDevCouple_I

    Joined:
    Oct 5, 2013
    Posts:
    837
  40. nickgravelyn

    nickgravelyn

    Joined:
    Jan 22, 2009
    Posts:
    143
    Awesome, thanks for the links!
     
  41. Deeeds

    Deeeds

    Joined:
    Mar 15, 2018
    Posts:
    427
    what's the cost of Timeline on mobile for animating transforms (scale, position, rotation, opacity, etc) on 2D objects compared to alternative means? I like the idea, and the curves, but worried about weight and inefficiencies. Not a coder, so wouldn't know where to begin in terms of testing performance.