Search Unity

  1. Unity 2019.2 is now released.
    Dismiss Notice

Blending from Mechanim and scaling Timeline playback speed

Discussion in 'Timeline' started by KapuraIII, Mar 27, 2018.

  1. KapuraIII

    KapuraIII

    Joined:
    Oct 25, 2017
    Posts:
    11
    I'm currently looking into timeline for a fighting game thing I'm working on. After initially poking around I found that you can easily blend out of and back into the mechanim by adjusting the ease in/out on the clips in the timeline. This means that I can control movement through mechanim, and use timelines for the attacks. So far, so good.

    But then I started looking at ways to change the playback speed of the Timeline. The only method that seems to work is changing the Update Method to Manual, then manually stepping playableDirector.time and calling .Evaluate(). Ok, that's fine, but you can't do this if the animator has a controller assigned, which means I don't get to use mechanim I guess?

    So my questions are:
    1. Is there another way to scale the playback speed of a timeline outside of manually stepping it?
    2. If not, is there a way to get the blending with mechanim to work with the manual updating? It works beautifully if the update method is game time.
     
  2. seant_unity

    seant_unity

    Unity Technologies

    Joined:
    Aug 25, 2015
    Posts:
    1,009
    Yes there is a way to scale playback speed, although it's only through script, and definitely not obvious.

    After calling playableDirector.Play(); you can change the playback speed of the timeline using

    playableDirector.playableGraph.GetRootPlayable(0).SetSpeed(0.5f); // e.g. play 2x slower

    This will scale the playback speed of the playableGraph generated from the timeline.
     
    1illGamer likes this.
  3. KapuraIII

    KapuraIII

    Joined:
    Oct 25, 2017
    Posts:
    11
    Thank you! This is exactly what I needed (for now, lol).

    It appears this is still in very active development, so my biggest feature requests outside of an API polish would be an event track (currently using a script that watches a custom track to trigger events) and a better multi-timeline interface (for authoring attack combos out of the attack timelines). But those are problems which will be more important later.