Search Unity

Question Kinematic ridigbody interferes with root animations and NavMeshAgent

Discussion in 'Navigation' started by Grant151, Nov 2, 2020.

  1. Grant151

    Grant151

    Joined:
    Sep 12, 2013
    Posts:
    65
    I have an NavMeshAgent, which is driven by root animations. When I attach a rigidbody and set it to kinematic, for some reason the root animations move the character a smaller distance (or sometimes dont move at all). What could be the reason here? I did some research, and kinematic rigidbodies should allow root animations to move the character properly, and have no effect on position.
     
  2. Havie

    Havie

    Joined:
    Oct 12, 2019
    Posts:
    89
    I am having a similar issue, except I have a normal rigidbody, root motion anims, and a navmesh agent. Trying to figure out the best way to handle movement on the beast. Up for solutions because right now I've overridden OnAnimatorMove and the player does this :

    _rb.MovePosition(_rb.position + Animator.deltaPosition);

    while the AI does this :

    AISoldier ai = (AISoldier)_Brain;
    if (ai._navAgent && StateMachine.CurrentState.GetType().Equals("MoveState"))
    {
    ai._navAgent.velocity = Animator.deltaPosition / Time.deltaTime;
    return;
    }
    Animator.ApplyBuiltinRootMotion();

    And it feels horrible