Search Unity

Reversing timeline

Discussion in 'Timeline' started by lawsonh, Nov 23, 2020.

  1. lawsonh

    lawsonh

    Joined:
    Jul 25, 2018
    Posts:
    80
    Hello Unity,

    I saw a few posts about reversing the timeline playback and it seems it is not possible.
    Do you guys have plans to support negative speeds for timeline? Is it being worked on? If so, what is the ETA? Seems like it is a very popular feature request

    Thank you
     
  2. seant_unity

    seant_unity

    Unity Technologies

    Joined:
    Aug 25, 2015
    Posts:
    1,516
    We don't have plans to support it at the moment, as not all playables types used by timeline can support it.
     
  3. lawsonh

    lawsonh

    Joined:
    Jul 25, 2018
    Posts:
    80
    Thanks for the response Seant. Is there any way we could get this feature into your plans somehow?
     
  4. seant_unity

    seant_unity

    Unity Technologies

    Joined:
    Aug 25, 2015
    Posts:
    1,516
    Could you explain the use case? It's always helpful when we understand the problem you are trying to solve, as opposed to the feature you need to solve it.
     
  5. lawsonh

    lawsonh

    Joined:
    Jul 25, 2018
    Posts:
    80
    I am creating a cutscene oriented game and would like an effect where the player can rewind the cutscene (going back in time). kind of like the effect in "life is strange" if you've played that.
     
  6. seant_unity

    seant_unity

    Unity Technologies

    Joined:
    Aug 25, 2015
    Posts:
    1,516
    You can play it in reverse by setting playableDirector.time via script and then
    • Manually evaluating it from script using playableDirector.Evaluate()
    • OR setting playableDirector.playableGraph.GetRootPlayable(0).SetSpeed(0); after calling the playableDirector is playing (plays at a speed of 0).
    The latter option will keep the engine playing timeline, which occurs between Update() and LateUpdate(). This is more efficient because timeline animation will be evaluated during the normal animation evaluation phase. When using Evaluate(), the animation phase needs be to run again.

    What won't work however is
    • Audio
    • Signals/Notfications
    • Cinemachine cameras with noise or effects that rely on the previous frame may give different results than playing forward.
    • Any custom playables that expect time to go forward.
    • Particles will work, but will be less efficient, as moving backwards causes them to re-simulate from the start of the clip.
    So if these are acceptable trade-offs, then it can be scripted.

    I hope that helps. And thanks for the updated use-case.
     
    dbdenny and Nemikolh like this.
  7. lawsonh

    lawsonh

    Joined:
    Jul 25, 2018
    Posts:
    80
    Ohh that's awesome. I'll try it out. Sounds like the only thing is I'll have to disable the particles in reverse mode.

    I'm just curious, do you know what the efficiency would be of doing that compared to playing the timeline normally with speed = 1? Assuming there are no particles.
     
  8. seant_unity

    seant_unity

    Unity Technologies

    Joined:
    Aug 25, 2015
    Posts:
    1,516
    The efficiency should be roughly equivalent. Animation might be slightly slower, as animation clips are optimized for forward playback, but it may not be a noticeable difference.

    For particles, I'd recommend measuring. I did some measurements recently and was pleasantly surprised how efficient the simulation was. It will be slower, but the length and complexity of particles will determine how much slower.
     
    lawsonh likes this.
  9. dbdenny

    dbdenny

    Joined:
    Mar 13, 2020
    Posts:
    12
    The second plan work for me perfectly!
    Save my life!
    Thank you bro!