Search Unity

Is it safe/efficient to build an entire animation system with Playables API?

Discussion in 'Timeline' started by PhilSA, Apr 5, 2017.

  1. PhilSA

    PhilSA

    Joined:
    Jul 11, 2013
    Posts:
    1,084
    Okay I realize this is kind of a vague question, but here it goes:

    I wish to make an animation system in Unity where each animation state is entirely "scriptable" and coupled with the game logic attached to it, where animations are modular instead of being all pre-placed in one mecanim graph, and where all state transitions are handled through code instead of being pre-determined and being triggered through blackboard-style variables. This hypothetical system would replace mecanim completely in my project and would be used for things like character animation, combo systems, etc...... You could imagine, for example, that "CharacterMovementState" would be a ScriptPlayable that handles the locomotion animation blend tree as well as moving the character, and "CharacterAttackingState" would be another ScriptPlayable that would handle attack animations, dealing damage and the combo system logic, etc...

    The whole point of this system is to make sure that there is no dissociation between an animation and its gameplay logic. So if for instance my sword attack animation gets interrupted mid-swing for whatever reason, the damage handling will necessarily be interrupted too. And vice-versa. I'm not even sure yet if it's a good idea to couple animation and gameplay logic, but I wanna try it

    But anyway, my question is: is this a risky idea? Is this what the Playables API was meant for? Does the API have some kind of non-negligible overhead that would make it "less performant" than mecanim? Was the Playables API mostly just made for cutscenes/set pieces/scripted events without too much effort spent on performance? Am I going to encounter a brick wall as soon as avatar masks, animation layers and root motion start coming into play?

    PS: I understand that the API is experimental at the moment, but I'm mostly interested in knowing if this would work in the final planned version
     
    Last edited: Apr 5, 2017
  2. laurentlavigne

    laurentlavigne

    Joined:
    Aug 16, 2012
    Posts:
    2,037
    Timeline is built on top of it so it's probably solid but I want to hear what others have to say from experience.
     
  3. mikew_unity

    mikew_unity

    Unity Technologies

    Joined:
    Sep 27, 2016
    Posts:
    97
    The playables API was created specifically to be lightweight and performant. The animation system was the first internal Unity system that was ported over to use the Playable API - and it is designed so that you can completely construct your playable graphs from code and run them.

    You can see in the exisitng docs / manual that you can build entire animation graphs purely from code (custom clips / mixers etc) - what 2017.x releases will provide is a significant expansion of the Playable API's scope to cover the Audio system, Video system and more. In addition, the Playable API is moving out of the experimental namespace. We can easily see migrating more systems to Playables - they have some pretty cool advantages - getting super low level access to these systems allows the community to build things via Playables that we could never have anticipated.

    We're pretty excited about the potential.