Nav mesh agent jitter on reaching destination

Ello

My nav mesh agent keeps jittering when the agent reaches the destination.

        if (Input.GetMouseButtonDown(0))
        {
            if (Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), out hit, 100, playerLayer))
            {
                Debug.DrawRay(Camera.main.ScreenPointToRay(Input.mousePosition).origin,Camera.main.ScreenPointToRay(Input.mousePosition).direction, Color.red,10f);
                agent.destination = hit.point;

            }
        }

The agent has a collider, ridged body & nav mesh agent componants

I have replaced the raycast with a standard transform,
removed the ridgedbody,
tried a fresh gameobject,
flattened the terrain.

Im stumped, any ideas?

1 Like

Try increasing stopping distance. If its set to zero it basically never can get to the destination.

3 Likes

Didnt work, put it up to 10, 2 and 5.

I adjusted the script to add +5 to the raycast y axis thinking the current coordinates were messing with the terrain colliders. Improvement, but after a few secs it starts jittering again…

I have the same problem. Did you ever find a solution?

Hi Guys, I had the same problem, and I realized that this only happens after the player with an object with a collider.

eg: if i have a Rock, the navigation should be baked, and the player should not be colliding with this rock. But if the baking missed out the rock, and when the player touches the rock, the player’s position seems to be “offset” by the collision and it will start to jitter and even rotate strangely even when he reaches the destination.

Solution 1: My player gameobjec’s rigidbody needs to be “Is Kinematic”
Solution 2: Make sure obstacles are baked into the Navigation “walkable”

Not sure if this is the same situation as yours.

7 Likes

Thanks so much for this!
Making the rigidbody “iskinematic” fixed it.

1 Like

HELL FROM 6 YEARS IN THE FUTURE. THANK YOU, HOLY SHIT THIS WAS PISSSING ME OFF! stopping distance fixed for me :slight_smile:

2 Likes

8 years!

1 Like

2022 ))

2023 :slight_smile:

1 Like

wow this saved my ass thanks

tyty worked for me

Worked for me, thanks a lot)