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

Resolved NavMeshAgent ignoring settings

Discussion in 'Navigation' started by Tkrain42, Jan 18, 2023.

  1. Tkrain42

    Tkrain42

    Joined:
    Jul 25, 2015
    Posts:
    43
    I'm using 2022.2.f1 with AI Navigation package 1.1.1

    I'm trying to use the NavMeshAgent's desiredVelocity to calculate movement for a CharacterController, which I've done before in previous versions of Unity without issue...

    It seems, however, that after I SetDestination on the NavMeshAgent, it takes off at a pretty fast clip, even if I'm not moving the CharacterController.

    I have agent.updatePosition and updateRotation set to false;
    I've tried resetting the nextPosition and velocity to correspond with movement.
    I've set the NavMeshAgent's settings, even at .1f, the agent is moving like the speed is 10f (even when I'm applying no movement whatsoever to the CharacterController).
    In fact, the only thing that stops the agent at all is setting the speed to zero, but then desiredVelocity is also zero. (It is, in fact, reporting the correct desiredVelocity at whatever speed you set it at, it's just moving the character at this arbitrary speed). It also seems to be ignoring angular speed.

    The only other setting it's respecting is stopping distance, but with auto-braking on or off, the behaviour is the same, if the stopping distance is greater than remaining distance, the character stops and the desiredVelocity becomes 0,0,0.


    Any idea?
     
  2. Tkrain42

    Tkrain42

    Joined:
    Jul 25, 2015
    Posts:
    43
    Resolved, not a bug at all.... I had forgotten to remove a prior version of my movement script before switching to a state machine version of my controller. Once I removed the old Mover script, all works as intended.