Search Unity

Stopping/cancelling Timeline

Discussion in 'Timeline' started by nathanjams, Jan 19, 2018.

  1. nathanjams

    nathanjams

    Joined:
    Jul 27, 2016
    Posts:
    304
    Hello,

    Edit, title is misleading. Apologies.

    Is there a simple way to skip a Timeline sequence? Say, if a Timeline is triggered, is there a way to assign a key command that would allow the user to skip the sequence and still have the events from the timeline triggered?

    Thanks in advance,
    Nathan
     
    Last edited: Jan 19, 2018
  2. seant_unity

    seant_unity

    Unity Technologies

    Joined:
    Aug 25, 2015
    Posts:
    1,516
    Not sure exactly what you mean by events triggered, but could you move the time on the playableDirector to at/near the end?
     
  3. nathanjams

    nathanjams

    Joined:
    Jul 27, 2016
    Posts:
    304
    I'm using some custom components that enable and disable different components. So if the player were to skip the given Timeline sequence I would like it that all commands that were to be sent through a sequence would still be completed even though the sequence didn't play through it's entire course.

    So as long as I have the final frame with the settings I want what you suggest should work. How would I move the time to the end of the clip through a key command?
     
    grimmzzf likes this.
  4. seant_unity

    seant_unity

    Unity Technologies

    Joined:
    Aug 25, 2015
    Posts:
    1,516
    To evaluate the last frame of the timeline, you can do something like

    playableDirector.time = playableDirector.playableAsset.duration; // set the time to the last frame
    playableDirector.Evaluate(); // evaluates the timeline
    playableDirector.Stop(); // deletes the instance of the timeline

    To have this activate on a key command, you'll probably need a monobehaviour that polls for the key, then executes that.
     
    Quentin0133, bison-- and nathanjams like this.