Search Unity

Muting/Unmuting as well changing the playback speed override track

Discussion in 'Timeline' started by khalid_mightybear, Dec 11, 2019.

  1. khalid_mightybear

    khalid_mightybear

    Joined:
    Sep 10, 2017
    Posts:
    36
    Hi,

    I have a timeline where the shooting animation is an override track. I'd like to be able to mute/unmute the override track at runtime as well as change the playbackspeed of the override track independently of the main animation track. I've managed to do it by modifying the assets and rebuilding the graph but it is costly to rebuild the graph everytime. Is there a way I can do this?

    I've taken a look at the code at https://forum.unity.com/threads/mute-unmute-a-track-via-scripting.509604/ to mute/unmute without rebuilding but it doesn't work for subtracks
     
  2. seant_unity

    seant_unity

    Unity Technologies

    Joined:
    Aug 25, 2015
    Posts:
    1,516
    You can mute/umute it, then call playableDirector.RebuildGraph(). This is somewhat of an expensive call, however. Otherwise you might be able to just use two separate animation tracks and use the suggestion above to mute the second track.
     
  3. khalid_mightybear

    khalid_mightybear

    Joined:
    Sep 10, 2017
    Posts:
    36
    I need to use an override track because the shooting track uses an avatar mask. Essentially I need a cheap way to transition between shooting to not shooting since that transition occurs quite frequently. Can I cache the graph somehow? I'm thinking of using 2 directors, one with shooting muted and the other without and switch between the 2? I'll need to keep track of the time played when transitioning between the 2 directors. Actually I guess I can have one director but have duplicate animation track, where one has the override shooting track and the other without.

    About my other question, is it possible to play different track with different playback speed without rebuilding the graph?
     
    Last edited: Dec 12, 2019
  4. seant_unity

    seant_unity

    Unity Technologies

    Joined:
    Aug 25, 2015
    Posts:
    1,516
    Right - as the base track does allow an avatar mask, it might still work but your shooting animation would need to not animate the root transform. The animation track doesn't take into account the avatar mask, only the used clips, when deciding whether or not to apply root transform offsets.

    As part of its subgraph an animation track produces an AnimationLayerMixerPlayable, where each input is a subgraph representing the particular track. You might be able to accomplish muting by simply disconnecting the input corresponding to that layer.

    The two director approach (or two timelines) will also work. Or if the shooting animation and mask can be placed on a separate track, you can have that as a separate timeline that you conditionally play or not. You can play multiple timelines and they will blend together, and their priority is based on which one was started last. Having your base timeline run, then having a second started/stopped when needed should work.


    No, the root playable (TimelinePlayable) controls the global to local time transformation for all clips at once. So changing the speed of one track isn't possible.
     
  5. Sword111

    Sword111

    Joined:
    Feb 28, 2016
    Posts:
    20
    Hi some great ideas thanks for the up load, this is a bit more advanced but been looking for the solution to a problem i have override track with a mask on a time line animation
    so the robot is on a timeline I’d like the animation to change with a trigger a mask, on /off... if for instance you were too close that would trigger waving you back with the free mask arm . This is easy to do in the animator with a parameter bool etc but how to in timeline ? Ive scoured the internet, any ideas? Be a nice idea for a tutorial ? Best H