Search Unity

Utilities uPlayableAnimation - PlayableAPI animation system

Discussion in 'Tools In Progress' started by echu33, Oct 26, 2022.

  1. echu33

    echu33

    Joined:
    Oct 30, 2020
    Posts:
    62
    Hello everyone, I made an animation plugin and hope it can help you during development.

    While Unity's animator controller's node base approach is visually straightforward. It did not scale well when the number of animation states start to pile up.

    In order to overcome these drawbacks. I wrote sevral scripts to handle all the animation transition based on Playable API. It's fully open-source and you can get get the project on gitub.


    Simply drag & drop the provided component on animated game object. The user can perform smooth transition between clip/animator controller at runtime

    Highlights Of The Plugin
    • Transition into different animation clip without wiring the animator controller over and over again..
    • Avatar mask (layer-animation) support.
    • Custom animation framerate at runtime
    • Custom animation speed at runtime
    • Custom fade-in time for each animation clip / animator controller at runtime
    • Support transition between exist animator controller at runtime.
    Feature Showcases

    Fire and Forgot Transition to Animationclip/Animator Controller

    Transition between different animator controller and animation clip at runtime


    Swap animation clip at runtime is also support

    Support Avatar Mask (Layerd animation)

    Customize animation framerate & animation clip speed at runtime


    Wtih custom fps,You can even create animation-LOD to save some performance.
    If you set animation clip to negative value, loop animation will play in backward.

    Also works for non-character animator



    Download and Try the Project
    you can donwload the plugin include example scene include usage examples on this Github Repo.

    Feedback
    I use this tool in my side porject as well.
    But since my usecase are certainly not able to cover all kinds of usage. Your feedback will be very helpful to make this tool more useful. Any feedback is welcome!
     

    Attached Files:

    Last edited: Nov 6, 2022
  2. joshcamas

    joshcamas

    Joined:
    Jun 16, 2017
    Posts:
    1,277
    Cool! This looks like a lightweight (and open source) version of Animancer, which is great!
     
  3. echu33

    echu33

    Joined:
    Oct 30, 2020
    Posts:
    62
    Yes, you're right.
    Since there's no other free plugin available online that use playable API. And yet it's so useful that people have to reinvent the wheel over and over again. I decided to make an open-sourced one.
     
    gareth_untether and joshcamas like this.
  4. echu33

    echu33

    Joined:
    Oct 30, 2020
    Posts:
    62
    In past few days, I've add several features and did some bug fixes.

    New Example Scenes:
    • custom framerate, speed test scene
    • example usage of using animation event in this plugin

    New Features:
    • custom framerate for each animator
    • custom animation speed for each animator
    • improve transition between animation clip with different clip length

     
    joshcamas likes this.
  5. bobadi

    bobadi

    Joined:
    Jan 3, 2019
    Posts:
    674
    hi, just tested, it works in 2022.1.

    this is promising, and I like the fps aspect of it. there's transition to self and humanoid animations, which is good.

    can you add transition offset to it?
    what do you think, would it be possible to replicate blend-tree in playable (with parameters)? better said blend tree of two blend trees, which is a strong feature in mecanim.

    I found a discussion about this (see last post), and an asset seems to be able to do it for years, though not many know about it
     
    Last edited: Nov 9, 2022
  6. echu33

    echu33

    Joined:
    Oct 30, 2020
    Posts:
    62

    My current work around for more complex blend tree is using a Animator controller contain a blend tree(and only the blend tree, for an overall more clean architecture), then assigned it to "AnimatorOutput". So the user are still using the old school mecanim blend tree/parameter for this AnimatorOutput. But the difference is that user can switch AnimatorOutput contains different runtimeAnimatorController at runtime and using weight to controller the mecanim blend tree's overall weight with other clip/animator playables.

    The player controlled walking unity-chan inside one of the example scene is a sample of these setup. The walking animation is actually blend from a runtime assigned animator controller. and user can still fire other AnimatiionClipOutput to the animator.

    The reason for this is the mecanim's blend tree(especially 2d blend tree)'s UX are just far too nice to not to use it. And it's quite complicated to re-write my own solution with all those UI.


    The setup are still quite lack of document and I'm certainly try to improve it. thanks for the feedback though!
     
    Last edited: Nov 10, 2022
  7. bobadi

    bobadi

    Joined:
    Jan 3, 2019
    Posts:
    674
    I see. it still sounds good and has some benefits over just using mecanim alone. I might consider adapting your solution. (if it will do offset)

    anyway, I was just thinking a virtual blend-tree, with static structure. no UI, just array of clips, virtual parameters, so you just fill in, not redo the blend tree every time.
     
  8. echu33

    echu33

    Joined:
    Oct 30, 2020
    Posts:
    62
    By the way, Is the transition offset you metioned means a way to offset the start frame/time of each animation clip?

    hmm I can imagine the feature you want, I'll survery if there's a solution for that.
     
    bobadi likes this.
  9. bobadi

    bobadi

    Joined:
    Jan 3, 2019
    Posts:
    674
    yes. that is the fixedTimeOffset in CrossFadeInFixedTime or normalizedTimeOffset in CrossFade.

    vortex seems to have it, might check this (Normalized start time after and Start time after fixed)
     
    Last edited: Nov 11, 2022
    echu33 likes this.
  10. echu33

    echu33

    Joined:
    Oct 30, 2020
    Posts:
    62
    Hi, i've add the fixedTimeOffset function inside my script.
    you can try it in the example scene No.11.

    upload_2022-11-14_20-29-34.png

    The next major change might be related to the script's inspector interface and a better example of mix usage between animator controller and this plugin.
     
    bobadi likes this.
  11. bobadi

    bobadi

    Joined:
    Jan 3, 2019
    Posts:
    674
    if you'll have time to work on this playables system
    let me summerize what I think a basic full-blown animation system needs
    so you don't waste effort on features that may be superfluous
    like animation events,
    (I think even animator controller integration might be something that can be done manually
    in late update and if processing is the same as a individual controller, that contradicts the
    biggest strength of a bare-bones playables controller, the performance)

    advantages of playables:
    1. clip.length
    2. dynamic blending
    3. fps lod

    need:
    1. normalized time of played state (clip playT - startT / clip.length)
    2. transition offset (again can be calculated from clip.length)
    3. synchronized blend (?)
    4. might be useful: another playable sampling. for lerping to/from pose etc
    5+ there are others, like pivotP that mecanim provides, but that can be calculated too

    3. example: synchronized walk and run.
    walkrunblend.gif
    have no idea how mecanim does it.
    all have different length. walk is 1.0 jog is 0.667 run 0.567
    they are cut to same beat (steps), but dif fps loop (?)


    ...
    is the playables executed in the same execution order as the mecanim is?
    mecanim has some strange execution cycle for animation update, but probably
    playables has the same thing
     
    Last edited: Dec 6, 2022
    echu33 likes this.
  12. echu33

    echu33

    Joined:
    Oct 30, 2020
    Posts:
    62
    I think I already handled the blending between clips with different length.

    The only exception is blending between clips and animation controller. That part is tricky so right now I use linear blend only.

    I’ll take a look about transition offsets features.
     
  13. bobadi

    bobadi

    Joined:
    Jan 3, 2019
    Posts:
    674
    that's good. transition to self is also doable if using same clip twice.
    with transition offset I think I meant using normalized time, because that is easier to work with, but unity's animation preview shows seconds, so that's not a showstopper.

    now it's just a blend tree of 4 clips that's remaining.

    (now that I think about it, it might be even possible in mecanim,
    with override controller, changing clips on the fly.
    yes, looks like was done in mecanimControl, 9 years ago :) )
     
    Last edited: Dec 7, 2022