Search Unity

updatePosition doesn't seem to work properly in unity 5

Discussion in 'Navigation' started by JohnTomorrow, Mar 18, 2015.

  1. JohnTomorrow

    JohnTomorrow

    Joined:
    Apr 19, 2013
    Posts:
    135
    I have a navmeshagent which is used to power mecanim rootmotion through desired velocity. to achieve this i had updatePosition = false. this way i could feed the desired velocity to rootmotion. this worked in unity 4.

    in unity 5, the navmeshagent does not stay synced with the gameobject's transform correctly. instead in the scene view i can see the navmeshagent's collider moving to the desired position separately. the navmeshagent's collider shouldn't move at all if updatePosition is false. when this moves out of sync, it throws all the calculations off and the entity assumes it is at the position because the navmeshagent is there.
     
  2. Dantus

    Dantus

    Joined:
    Oct 21, 2009
    Posts:
    5,667
    What exactly are you doing?
    You take the velocity from the NavMeshAgent and pass that to Mecanim. Do you modify the position yourselves as well or do you pass the control for that to Mecanim?
     
  3. Jakob_Unity

    Jakob_Unity

    Joined:
    Dec 25, 2011
    Posts:
    269
  4. JohnTomorrow

    JohnTomorrow

    Joined:
    Apr 19, 2013
    Posts:
    135
    root motion is controlled by a script. i take in the root motion and modify it based on my needs through OnAnimatorMove() the vector is then used to move a character controller. maybe this is strange to do, but it used to work in 4.

    how would i keep the simulated position the same as the actual gameobject's position so that i can move the object along a path correctly?
     
  5. JohnTomorrow

    JohnTomorrow

    Joined:
    Apr 19, 2013
    Posts:
    135
    i'm not sure if this changed recently but i added navAgent.nextPosition = transform.position and it fixed my issue.
     
  6. Jakob_Unity

    Jakob_Unity

    Joined:
    Dec 25, 2011
    Posts:
    269