Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice

Root Motion and Anims build in Unity

Discussion in 'Editor & General Support' started by BoaNeo, Apr 28, 2020.

  1. BoaNeo

    BoaNeo

    Joined:
    Feb 21, 2013
    Posts:
    56
    I am having some issues understanding root motion and how it applies to animations build in Unity (I.e. the animations are NOT imported with the model but are build in Unity's animation editor)

    Basically, the root node is moving and rotating alright, but this motion is never applied
    to the parent game object (where the Animator lives), so it always stays in the same place.

    I have an almost identical setup with another model where the animation is imported with the
    mesh and that works fine.

    Both the working and the broken model has the same basic hierarchy:


    + prefab (Basically a Transform with Animator Component)
    + root
    + bones (Bones-hierarchy)
    + renderer (Node with SkinnedMeshRenderer Component)


    The Rig is imported like:
    -------------------------
    Animation Type: Generic (Also tried all the other options, no difference)
    Avatar Definition: Create From This Model
    Root node: root
    Skin Weights: Standard (4 bones)
    Optimize Game Object: No

    The Animator is setup like
    --------------------------
    Controller: SomeController
    Avatar: SomeAvatar (generated, but also tried picking an avatar from a different model)
    Apply Root Motion: Yes
    Update Mode: Normal (tried all)
    Culling Mode: Cull Update Transforms (but I've tried all)

    There are several animations in the controller, and only two of them has root
    motions. One has root:position keys and the other has root:Rotation keys. I can
    see that the root node transform is updating these properties when animating. And all
    animations as well as the controller is working fine other than root motion not being applied.

    I was trying to see if I could get it working from code using OnAnimatorMove and
    ApplyBuiltInRootMotion and noticed that

    animator.runtimeAnimatorController.animationClips[x].hasRootCurves

    is false for all clips. It seems to me that somehow the connection between the
    specified root node in import settings and the root keys in the animation is
    lost?

    (Oh, and this is Unity2019.3.8f1)
     
    Last edited: Apr 29, 2020
  2. BoaNeo

    BoaNeo

    Joined:
    Feb 21, 2013
    Posts:
    56
    Hm, so it seems that for some reason, Unity is not adding root motion curves to the animation automatically (As I understand it's supposed to?).

    I found this:
    https://forum.unity.com/threads/make-root-motion-in-animation-clip.250723/

    And tweaked the AddMotionCurve script posted there for my use-case, then ran it on the .anim files I'm having issues with and, lo-and-behold, Root motion.

    Anyone have any idea why Unity doesn't do this by itself? Again, this is an animation (.anim) that was created in Unity, it wasn't imported from some obscure 3rd party file format that might not be properly supported.