Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Play/Skip Timeline through code

Discussion in 'Cinemachine' started by Nihil688, Feb 7, 2020.

  1. Nihil688

    Nihil688

    Joined:
    Mar 12, 2013
    Posts:
    503
    Hello,
    I am trying to create a system in my game for my cutscene to be able to skip to the next part and play a specific part. The only thing I've currently managed to get working is getting the PlayableDirector and changing it's time variable to something specific and hardcoded.

    Is there a way to get the camera durations and/or start times within a timeline through code so that I don't have to set it up hardcoded?
     
  2. seant_unity

    seant_unity

    Unity Technologies

    Joined:
    Aug 25, 2015
    Posts:
    1,516
    You can get the timeline from the playable director with

    var timeline = (TimelineAsset) playableDirector.playableAsset;

    You can iterate the tracks with TimelineAsset.GetOutputTracks(), and then the clips with TrackAsset.GetClips().

    TimelineClip.start will tell you the time the clip starts, and TimelineClip.duration the clips duration.
     
    awsapps and Nihil688 like this.
  3. Nihil688

    Nihil688

    Joined:
    Mar 12, 2013
    Posts:
    503
    Thank you, I had tried that but I didnt cast it to TimelineAsset so I never got the right results