Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Blending playable assets with the Playable API

Discussion in 'Timeline' started by CodeKiwi, Jul 15, 2017.

  1. CodeKiwi

    CodeKiwi

    Joined:
    Oct 27, 2016
    Posts:
    119
    I was thinking of using the Playable API to control my animations instead of the state machine. I used the Playable Director to create two Playable Assets (idle and attack). Each playable asset contains two skeletal meshes (body, head) with their own animations. They also control audio, particle effects, color tint and animate hit boxes.

    It seems like the playable assets can be used directly with the playable graphs. The code below plays the audio in the asset.

    Code (CSharp):
    1.  
    2. public PlayableAsset testPlayable;
    3. ...
    4. Playable playable = testPlayable.CreatePlayable(playableGraph, this.gameObject);
    5. playableOutput.SetSourcePlayable(playable);
    I’d like to set the exposed properties for the playable. I thought I could use playable.GetGraph().GetResolver().SetReferenceValue() but the reference table seems to be null.

    Questions:
    1: Is it ok to use playable assets for character states or should I only use them for cut scenes?
    2: How do I set the exposed properties for a playable? e.g. character to apply animation to.
    3: Does a playable asset work with the mixer? I’m guess it would just apply the same weight to all tracks when blending.
    4: If the mixer does automatically control mixing is it possible to not mix the audio channels? e.g. don’t want sound to fade out / in between states.
     
  2. seant_unity

    seant_unity

    Unity Technologies

    Joined:
    Aug 25, 2015
    Posts:
    1,516
    1. Playable Assets can be used for character states, or just about anything. Their purpose is to be a serializable asset that can generate a playable graph. Timeline is simply just nested playable assets.
    2. For that you need to set an IExposedPropertyTable as the resolver on the graph. The playable director implements this interface, and the graph resolver is actually the Playable Director for Timeline playback, but you are free to implement your own. It's probably best to use a component so you can serialize references with the scene.
    3. Yes. You can make your own mixer, and even have your PrepareFrame automatically set weights for it's input playables.
    4. Yes. The mixer just blends with the weights you set. So you if don't change weights for audio, it won't fade.

    I hope that helps.
     
  3. CodeKiwi

    CodeKiwi

    Joined:
    Oct 27, 2016
    Posts:
    119
    Cool, thanks.