Search Unity

How to Modify PlaySpeed of TimeLine?

Discussion in 'Timeline' started by ghzhouskr, Feb 19, 2019.

  1. ghzhouskr

    ghzhouskr

    Joined:
    May 9, 2013
    Posts:
    2
    As Titile
     
  2. seant_unity

    seant_unity

    Unity Technologies

    Joined:
    Aug 25, 2015
    Posts:
    1,516
    Code (CSharp):
    1.         void PlayAtSpeed(PlayableDirector playableDirector, float speed)
    2.         {
    3.             playableDirector.RebuildGraph(); // the graph must be created before getting the playable graph
    4.             playableDirector.playableGraph.GetRootPlayable(0).SetSpeed(speed);
    5.             playableDirector.Play();
    6.         }
    7.  
     
    JoRangers, robrtoprz and bstockwell like this.
  3. alanmthomas

    alanmthomas

    Joined:
    Sep 7, 2015
    Posts:
    197
    I attempted this in my project with less than favorable results. I am using Timeline to control cutscenes in my game. I have a fast forward button that is intended to speed the playback of the specified timeline. Including that "RebuildGraph" call caused the timeline to behave oddly if it is already playing. I pulled the line and it works as expected. Do you think this could be problematic for me or is it safe to set the speed without that function?
     
    TheWarper likes this.
  4. seant_unity

    seant_unity

    Unity Technologies

    Joined:
    Aug 25, 2015
    Posts:
    1,516
    The RebuildGraph call is only there if the graph is not yet playing. If it is already playing, there is no need for it.
     
    TheWarper and Acrops like this.