Search Unity

  1. Looking for a job or to hire someone for a project? Check out the re-opened job forums.
    Dismiss Notice
  2. Unity 2020 LTS & Unity 2021.1 have been released.
    Dismiss Notice
  3. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

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

    Unity Technologies

    Joined:
    Nov 26, 2012
    Posts:
    1,674
    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

    Unity Technologies

    Joined:
    Nov 26, 2012
    Posts:
    1,674
    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

    Unity Technologies

    Joined:
    Nov 26, 2012
    Posts:
    1,674
    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

    Unity Technologies

    Joined:
    Nov 26, 2012
    Posts:
    1,674
    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:
    132
    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

    Unity Technologies

    Joined:
    Nov 26, 2012
    Posts:
    1,674
    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:
    21
    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:
    1,495
    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.
     
    petzichila likes this.
  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:
    142
    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:
    3
    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:
    1,495
    @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:
    3
    We are basically creating animations since we load them via gtb files. We have the raw data, then loaded into an animation clip.
     
  18. frankcarey

    frankcarey

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

    DrabanL

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

    TobyWu

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

    Kybernetik

    Joined:
    Jan 3, 2013
    Posts:
    1,495
    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.
     
  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
     
unityunity