Playable API use case

I’m currently trying to get my head around the playable api.

The playable api seems to be good if you want to link a specific one-shot clip to an gameobject, but it seems for more complex situations Mecanim is the way to go, but I can’t believe that this is the only use case.

It would be great if someone could list some use cases here, unfortunately the documentation doesn’t make it clear (at least for me) when to chose the Playable API over Mecanim.

The playables API give you all the blending power of mecanim.

When you create an AnimatorController and play it with an Animator component, internally we do create the Playable graph for you based on your controller.

By example if you look at a transition between two clip, internally it implemented with a
https://docs.unity3d.com/ScriptReference/Experimental.Director.AnimationMixerPlayable.html
and two
https://docs.unity3d.com/ScriptReference/Experimental.Director.AnimationClipPlayable.html
connect as input into the AnimationMixerPlayable,
while the transition occur mecanim simply update the weight for both input with https://docs.unity3d.com/ScriptReference/Experimental.Director.AnimationMixerPlayable.SetInputWeight.html

Take a look at this blog post, the API has changed a little since then but still give you an idea of what you can do

One thing that I foresee with playable is that people will start to write dedicated controller for small purpose like a swim controller or a Climb controller and with the playable they will blend from one to the other when needed. There is no need to have a One controller solution that can handle all case in your game because if you think about it you don’t need to have a controller that handle swiming and locomotion at the same time

2 Likes

I usually use animator controller layers for climbing/swimming, do you see any advantage using playables over the traditional mecanim workflow? Or is it more like an alternative to mecanim for ppl which prefer to call animations by code?

Thanks for the links.

The advantage in this case is to reduce memory footprint, if you have a big controller that can do everything it mean that it also need to allocate more memory internally. By splitting you’re controller in smaller chunk and blending them only when necessary if allow you to free some resources.
When you’re character is not climbing a ladder you don’t need to have all these animation clips related to climbing to be loaded in memory.

Also for the load time if you have a controller with 200 animation clip when you load your level you need to also to load all those animation clip.

Divide and conquer!

8 Likes