Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Load non legacy animation at runtime in a build

Discussion in 'Animation' started by Tohrak, Jun 3, 2019.

  1. Tohrak

    Tohrak

    Joined:
    Nov 2, 2015
    Posts:
    12
    Hello,
    I'm trying to allow user to load a FBX file with animations at runtime. I'm using the asset Trilib for this.
    My issue is that it doesn't work with generic AnimationClip (for Animator) at runtime in a build. I'm expectedly getting this error : "Can't use AnimationClip::SetCurve at Runtime on non Legacy"
    It works only in the editor.

    Is there a plugin or extension or whatever that could help me SetCurve() at runtime ?
    Or will we have the possibility to do this natively in the not so far future ?

    I'm trying to work with legacy animation for now, but I don't have all the feature I would like to use. I would like to use multiple simultaneous animation, rewind animation, reset animation, either loop or not animation, modulate speed etc.

    Thank you for your time.
     
  2. Kybernetik

    Kybernetik

    Joined:
    Jan 3, 2013
    Posts:
    2,555
    I don't think it's possible to load external Mecanim animations at runtime.

    Legacy can do all the things you listed though.
     
  3. Tohrak

    Tohrak

    Joined:
    Nov 2, 2015
    Posts:
    12
    Thank for your reply. It's sad that we can't create those macanim animations at runtime. :(

    I will indeed try to use legacy animation, even tho I'm struggling to simply play two animation at the same time on the same object, without blending.
     
  4. Kybernetik

    Kybernetik

    Joined:
    Jan 3, 2013
    Posts:
    2,555
  5. Tohrak

    Tohrak

    Joined:
    Nov 2, 2015
    Posts:
    12
    Thank you,
    I did already tried to use it, but I did not find a way to play two animation without one stopping the other, or both playing only half of the animation (Like a door will stop its animation midway, because of the weight = 0.5f).

    Another problem I encounter is that, when I set AnimationState to additive, the animation act really strangely and do its motion far too much. (For exemple, a door will spin on its axis ~4 time instead of only opening slowly at 90°) But this may be a bug with the library Trilib I use.

    I will look further into it !

    ps : I just tried to create an animation manually and set it to additive, and I have the same problem. I have to set the weight of the AnimationState, after the Play() (Before doesn't works) at 0.05f or so. I don't know why, it's strange
     
    Last edited: Jun 3, 2019