Search Unity

Mecanim AnimationClip at Runtime

Discussion in 'Animation' started by ABouenard, Apr 9, 2018.

  1. ABouenard

    ABouenard

    Joined:
    Nov 10, 2017
    Posts:
    11
    Hi,

    Following numerous previous requests, I wonder when AnimationClip::SetCurve will be available at runtime.

    Previous requests were answered that it would be available in the future:
    And there is even a unity feedback thread for this type of request:
    Is there any news about it?

    Thanks very much!
     
    ModLunar and joaoborks like this.
  2. Mecanim-Dev

    Mecanim-Dev

    Joined:
    Nov 26, 2012
    Posts:
    1,675
    In 2018.2 we added the possibility to build a humanoid and generic clip at runtime for the new Animation C# jobs, so we are getting closer.

    This is still on our roadmap but I have no ETA for this feature.
     
    alexchesser likes this.
  3. ABouenard

    ABouenard

    Joined:
    Nov 10, 2017
    Posts:
    11
  4. Mecanim-Dev

    Mecanim-Dev

    Joined:
    Nov 26, 2012
    Posts:
    1,675
    currently it all hidden internally, but basically when you call
    Code (CSharp):
    1.  
    2. public static TransformStreamHandle BindStreamTransform(this Animator animator, Transform transform);
    3. public static PropertyStreamHandle BindStreamProperty(this Animator animator, Transform transform, Type type, string property);
    4.  
    internally we are building a animation clip with those bindings, what is an animation clip? a list of curve with a bindings defining which unity properties is animated by this curve.

    So now since we can generate a mecanim clip at runtime, the only thing remaining to do is to validate that SetCurve does work for legacy, generic and humanoid clip.
     
  5. ABouenard

    ABouenard

    Joined:
    Nov 10, 2017
    Posts:
    11
    So excited to hear such news!
    So now the backend of SetCurve is here, would you say that it could be part of a release in 2018?

    Thanks!
     
  6. Mecanim-Dev

    Mecanim-Dev

    Joined:
    Nov 26, 2012
    Posts:
    1,675
    unfortunately I can't give you an ETA but it on our plan
     
  7. ABouenard

    ABouenard

    Joined:
    Nov 10, 2017
    Posts:
    11
    Ok, nevermind for the ETA :)

    As part of the 2018.2, will there be examples of how using BindStreamTransform/BindStreamProperty functions can help in handling AnimationClip in runtime?
     
  8. Mecanim-Dev

    Mecanim-Dev

    Joined:
    Nov 26, 2012
    Posts:
    1,675
    they won't help at all for handling AnimationClip at runtime because they are unrelated. But the backbone used by those function will allow us to enable SetCurve for humanoid and generic rig.

    Basically when a user call BindStreamTransform/BindStreamProperty we are injecting binding into an animation clip, and now since 2018.2 those animation clip can generate an humanoid or a generic clip at runtime.

    So the new thing in 2018.2 is that we can now generate at runtime an humanoid or a generic clip from animation clip.
    This is all internal stuff that normally user are not aware of.
     
    deus0 likes this.
  9. deus0

    deus0

    Joined:
    May 12, 2015
    Posts:
    256
    Can 'BindStreamTransform' be used as a work around to 'SetCurve'? Are there any code examples? I would like to get my dynamic animations to work at runtime with the animator system.
     
    Last edited: Nov 3, 2018
  10. Mecanim-Dev

    Mecanim-Dev

    Joined:
    Nov 26, 2012
    Posts:
    1,675
    no it cannot be used directly as a work around to SetCurve, because with BindStreamTransform you are injecting a new bindings but there is no curve associate with this bindings. it simply give you a write access to your animated value

    But with some imagination you could use a animation jobs to implement your own custom animation clip that play your custom curve
     
  11. joaoborks

    joaoborks

    Joined:
    Jul 7, 2015
    Posts:
    29
    Any updates on this matter? I'm working right now in a project that needs specifically to import these humanoid animations from external sources realtime. I'd like to know if there's any other way to do it.
    AnimationClip.SetCurve
    on non-generic rigs would completely solve it.
    Currently we have to use the Human Pose Handler and replicate the position and rotation of each bone (so I believe we can't even optimize the transforms). Anyway, will appreciate any reply, thanks!
     
    Last edited: Feb 21, 2019
    CAMBCN, ModLunar and code-blep like this.
  12. Kybernetik

    Kybernetik

    Joined:
    Jan 3, 2013
    Posts:
    2,570
    Well it has been another year with no news so I figured I'd add another reminder that people actually want this. Surely Mecanim cannot have been designed so badly as to make it impossible to do what the Legacy system could do half a decade ago.
     
  13. petzichila

    petzichila

    Joined:
    Jan 27, 2018
    Posts:
    2
    I agree it's kind of ridiculous to be allowed to write animation in the Editor but not in the build. I'm stuck with a project I can't export to any platforms.
     
  14. TheZombieKiller

    TheZombieKiller

    Joined:
    Feb 8, 2013
    Posts:
    265
    Are there any updates on this? It's a bit of a blocker as using legacy clips locks you out of using not only the Animator component but the Playables API too, so I'm stuck with legacy animation. Having a date to look forward to for this feature would be immensely appreciated.
     
    organick likes this.
  15. Linkupdated

    Linkupdated

    Joined:
    Sep 24, 2014
    Posts:
    9
    It has been so long since many other requested this. I wonder when it will be possible to do this? Surely in 2020 after like many many years it's possible to load AnimationClip at Runtime using playables?
     
  16. Kybernetik

    Kybernetik

    Joined:
    Jan 3, 2013
    Posts:
    2,570
    @Linkupdated It is possible to load existing AnimationClips at runtime using Resources.Load, Asset Bundles, or the Addressables system and play them using playables. This thread is about creating new animations at runtime.

    I said the same in my reply to your Animancer review, but I'm not sure if the Asset Store gives you a notification about that.
     
  17. Linkupdated

    Linkupdated

    Joined:
    Sep 24, 2014
    Posts:
    9
    We are basically creating animations since we load them via glb files. We have the raw data, then loaded into an animation clip.
     
    Last edited: Jul 12, 2023
  18. frankcarey

    frankcarey

    Joined:
    Jul 15, 2014
    Posts:
    14
    @Mecanim-Dev Surely, this is on someone's roadmap at Unity?
     
    Linkupdated likes this.
  19. DrabanL

    DrabanL

    Joined:
    Nov 13, 2014
    Posts:
    41
  20. TobyWu

    TobyWu

    Joined:
    Oct 10, 2019
    Posts:
    7
    Same request today, anything new?
     
  21. Kybernetik

    Kybernetik

    Joined:
    Jan 3, 2013
    Posts:
    2,570
    This thread is about creating new Animation Clips at runtime, not adding new states to an Animator Controller, but neither one is possible anyway.

    Animancer uses Unity's inbuilt IK system so it should give identical results to Mecanim. The only reasons I can think of for it to not work would be if you're using a Generic Rig (it needs to be Humanoid) or if you haven't enabled Foot IK (the Uneven Ground example uses the IK Pass, which is a completely separate part of the IK system). If that doesn't help, feel free to use any of the listed Contact methods to send me a minimal reproduction project showing the difference between what you're getting with Animancer vs. Mecanim so I can take a look at it.
     
    TigerHix likes this.
  22. sunelda

    sunelda

    Joined:
    Jun 13, 2017
    Posts:
    4
    Hello Kybernetik!
    Don't know if you got my email. I deleted my post since it is no longer relevant.
    Thank you so much!
    Animancer is simply amazing and the solution to all our animation issues.
    Best,
    Sunelda
     
  23. HugoDidimo

    HugoDidimo

    Joined:
    Aug 6, 2018
    Posts:
    3
    Any news on this subject? We need to load characters during runtime, including animation, and would be great if we were able to use mecanim.
     
  24. Iron-Warrior

    Iron-Warrior

    Joined:
    Nov 3, 2009
    Posts:
    838
    Also looking for this functionality. Is there a blocker that prevents this from working at runtime? Are the curves being compressed and optimized by a module that is only accessible in the Editor?
     
  25. Tulrath

    Tulrath

    Joined:
    Feb 1, 2015
    Posts:
    13
    Any news on this? I need to be able to dynamically build animation clips at runtime and use SetCurve() on mechanim. Any ETA?
     
    adamkvd likes this.
  26. Linkupdated

    Linkupdated

    Joined:
    Sep 24, 2014
    Posts:
    9
    Still hoping for progress on this! Would help us a lot to be able to load Mecanim animations at runtime. We use Trilib to load assets by the way.
     
    TigerHix and adamkvd like this.
  27. adamkvd

    adamkvd

    Joined:
    Nov 28, 2017
    Posts:
    4
    Same here. Currently bound to use the legacy Animation system because of this.
     
  28. TigerHix

    TigerHix

    Joined:
    Oct 20, 2015
    Posts:
    69
    Same here. This is so sad...
     
  29. KeigoTakamura

    KeigoTakamura

    Joined:
    Mar 8, 2022
    Posts:
    6
    Isn't this topic progress in Unity2023 too?
     
  30. Linkupdated

    Linkupdated

    Joined:
    Sep 24, 2014
    Posts:
    9
    More than 1 year later. Any news or workaround on this? Thanks!
     
  31. ZorakTheFox

    ZorakTheFox

    Joined:
    Mar 3, 2021
    Posts:
    1
  32. kodra_dev

    kodra_dev

    Joined:
    Oct 31, 2022
    Posts:
    108
    5 years later. Still not a thing?

    The Unity cycle:
    1. Make a new system and mark the old one legacy
    2. Don't support features that the old system has being able to do for a decade
    3. (negative) Profit
     
    TigerHix likes this.
  33. kodra_dev

    kodra_dev

    Joined:
    Oct 31, 2022
    Posts:
    108
    "so we are getting closer." -- Unity staff, 2018

    By the way the last time Mecanim-Dev posted on this forum was 2021. I guess Unity has abandoned Mecanim. Probably spending their resources on yet another new animation system.

    It will come out in 2025 and make Legacy and Mecanim both legacy, but doesn't offer feature parity at all.
     
    Last edited: Dec 20, 2023
    TigerHix and Kybernetik like this.