forwardSpeed is changing during the update() function while enemy is staying

When enemy comes to waypoint and stop for dwalling he is vibrating becuase my forwardSpeed is going from 3 to 0 few times during dwalling period. There is a same behavior when enemy attack me and I escape when he wait for a sec and go back to his position.

I don’t know what is an issue here. I have checked and I have the same code as you have on your lections.

The NavMeshAgent is trying to “reach” the destination, but it can never truly get there.

Try adding this to the Update() method of Mover()

if(GetComponent<NavMeshAgent>().remainingDistance<1.0f) GetComponent<NavMeshAgent>.isStopped=true;

and this will also mean that in MoveTo(), you’ll need to add:

GetComponent<NavMeshAgent>().isStopped=false;

Thanks @Brian_Trotter a lot, it works fine now. But what I want to ask you now, is why this is working in your example without this code? I can’t see that your enemy is vibrating but you didn’t put this part in your Mover class.

It’s one of those things that didn’t come up when we recorded the course, and it doesn’t strike everybody. I’m thinking there might have been a change to the NavMeshAgent logic in recent versions because the once in a blue moon questions on this topic have morphed to almost daily.

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms