0
\$\begingroup\$

I am using NavMeshAgent in my Unity project to calculate and move my object to a particular location.

When I do:

navMeshAgent.destination = destinationPt

the object starts moving, but the motion of the object is very jerky.

Is there a way to override the function which is responsible for the jerkiness of the object motion? Or is there a way I can remove the jerkiness of the motion some other way?

I also tried setting

navMeshAgent.updatePosition = false

after which I use

navMeshAgent.CalculatePath(destinationPt, path)

to get the path, but then after this I am not able to figure out how to write my own logic to make the object move. I want a smooth motion with a given acceleration and a max velocity.

\$\endgroup\$
3
\$\begingroup\$

Your camera movement is jerky, not the movement of your object.

When updating the camera position it's best to use LateUpdate, this ensures that the update takes place after all of the other Update calls. This means the position of the camera will be accurately positioned for the same frame you're updating. As stated in the documentation:

For example a follow camera should always be implemented in LateUpdate because it tracks objects that might have moved inside Update.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.