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

Root animation doesnt move

Discussion in 'Animation' started by dienat, Feb 22, 2017.

  1. dienat

    dienat

    Joined:
    May 27, 2016
    Posts:
    417
    I have used three different animations packs with root animations and none works. Just one, mixamo, moves the character with animation but then resets its position back, the other two dont move the character forward.

    I have set a script in the character with animator.applyRootMotion = true;

    The models use mecanim humanoid type, loop checkbox enabled and its not in bake position in the animation settings, so have no idea why its not moving.

    Just set an animation controller with default state to the moving animation
     
  2. dienat

    dienat

    Joined:
    May 27, 2016
    Posts:
    417
    i have deleted the script component which i used to enable the root motion and used root motion enabled in the component and now it works

    But if i do it in script doesnt work using

    private void Awake()
    {
    animator = GetComponent<Animator>();
    animator.applyRootMotion = true;
    }

    The problem was that i was using OnAnimatorMove and that makes applyRootMotion not working by script

    But if i cant use OnAnimatorMove how can i update the agent velocity so that it fits the animator speed?

    I wanted to use agent.velocity = animator.deltaPosition / Time.deltaTime; in the OnAnimatorMove
     
    Last edited: Feb 22, 2017
  3. TrickyHandz

    TrickyHandz

    Joined:
    Jul 23, 2010
    Posts:
    196
    There is a nice thread about this type of behavior here:
    https://forum.unity3d.com/threads/navmeshagent-mecanim-animator.262951/

    The idea discussed in the linked thread is that rather than using the animator to control the NavMeshAgents velocity, you can use the NavMeshAgent.desiredVelocity to control how your AnimatorController is behaving. I think that should get you closer to what you are trying to accomplish.
     
    theANMATOR2b likes this.
  4. dienat

    dienat

    Joined:
    May 27, 2016
    Posts:
    417
    I am using root motion in the end, its the only option to achieve a realist movement i found.