So I’m mucking around with the Playables API to try and feel out what’s possible with it. Ran into a few entertaining snags already, so I figured it would be best to start a thread and help out anyone else interested in it. This is kind of Feedback, kind of Support so I admit I wasn’t exactly sure where to put it, but I figure I’m going to break something at some point anyway.
Those unaware of what Playables are (or are promising to be, given they’re still in an experimental state at the moment), the Manual discusses them here. Tracking down the Scripting API docs is… awkward because the Experimental namespace doesn’t appear in the navigation dropdown for some reason but the pages are there; you just have to use the links in the Manual page to find them. There’s also a Unite video on upcoming animation features which shows off Playables; the Playables section kicks off here.
The gist of them is that it in theory lets you extend on the Mechanim Statemachine system; rather than the Animator component being wedded to one monolithic state machine, you can blend between them, blend in other clips and do all other kinds of shenanigans with them via scripting; you can blend animation clips with animation clips, animation clips with state machines, state machines with other state machines and so on.
In my case, what I’m particularly hoping to be able to use this for is weapons animations in a top-down game. The design calls for a wide variety of weapon types all with wildely different mechanics… and hence, wildly different statemachines needed to animate them. I’ve previously experimented with trying to do this with a sort of primitive ‘moveset swapping’ using Animation Override Controllers to define the precise animation clips and having the structure for every possible weapon statemachine within the AC tied to a different int ‘weaponType’ parameter but it’s… messy, clunky for making changes with and generally not the nicest system to operate on.
Here, I’m hoping to be able to store the statemachine for each weapon within the weapon itself, such that it is responsible for declaring how it gets used and animated rather than trying to cram every possible system in the main character anim controller. Quite obviously this is going to involve AnimatorControllerPlayables and a fair amount of shenanigans just to get it working. In a beautifully ideal world I’d love to set it up Dark Souls-style with swappable weapons in each hand (so you might in total have three statemachines working; left hand weapon, right hand weapon and the main character, or two for a two-handed weapon and so on). How well you can blend statemachines together using Playables - particularly if they can be layered over each other with masking - is going to be the interesting question and the real limiting factor.
At the moment I’m just doing tests and trying various systems - there is no weapon manager or anything, it’s pure bare-bones prototyping. So far what I’ve observed is:
-
If your Animator has an animator controller predefined, it will override any Playable set with Play(); - you’ll have to remove it first (animator.runtimeAnimatorController = null; or just unset it in the Inspector) to get it to work.
-
When using the MixerPlayable, never let your input weights total anything other than 1.
-
Really, really wish we had some way of naming Playables just so the graph visualiser was easier to read.
-
You don’t set animation controller parameters through the Animator any more; they have to be set in the Playable itself. Same functions, though.
-
As I’m not using Root Motion, can’t comment on how well that works/doesn’t work with Playables and multiple animation controllers.
-
Related to the above… can’t seem to get ‘Get’ parameters to work, ie animation parameters driven by curves in the animation clip.
Anyone else done anything with the Playables API; any advice to add? The loss of parameter curves hits kind of hard; I’m only getting the default values out from the AnimationControllerPlayables, has anyone had any luck with getting that to work or should I expect that in a later Unity version?