Movement seems not to be smooth even though it's done in FixedUpdate

Hey,

I’m using AIPath and I’ve noticed that the characters aren’t moving smoothly(even when I’ve got no spikes on my machine). The calculations and movement are done in FixedUpdate without rigidbody. Does anyone know how to solve it?
Example:

And the values of AIPath:

Hi

That looks odd.
What are the settings for your Seeker component (in particular the Start End Modifier settings)?

Also. Why are the calculations done during FixedUpdate if you are not using a rigidbody? By default they should be done during Update if no rigidbody is used. Have you modified the scripts to do that?

Hey Aron,

These are my seeker’s settings:

Yes, I’ve overrided FixedUpdate from AIPath in my script. The reason for this is that I use A LOT of characters, and using Rigidbody version of yours is computation expensive. That’s why I tried just to use the lines of code from Update in FixedUpdate. So the movement will be the same nevertheless FPS of the game.

Ok. I assume you changed “Time.deltaTime” to “Time.fixedDeltaTime” in the code then.
Make sure you also remove the normal Update method.

Hm… I’m no sure what is going wrong here. Can you replicate this in any of the example scenes?
Try to disable the “Graph Raycasting” option in the Start End Modifier.

Check the Unity Time Manager -> Fixed Timestep option. Make sure it is a reasonable value (like 1/50 = 0.02).

Oh, that was it! The fixed Timestep was at 0.1.

Now the movement smoothness is just fine, but the direction change is taking way too long. No matter how big rotation speed. Do you know what causes it?

That’s due to the fact that it is limited by its acceleration. I know this is maybe not the most obvious thing (I plan to change this in the future). When an object is rotating it experiences an acceleration (see Centripetal force - Wikipedia) and since the acceleration is limited, the rotation speed it limited.
Currently however the acceleration of the AIPath script is not exposed in the inspector (another reason I plan to change things in the future). You will find it around line 213 in the AIPath.cs script

// a = v/t, should probably expose as a variable
float acceleration = maxSpeed / 0.4f;

The value ‘0.4’ is the approximate number of seconds it should take for the AI to reach its top speed. Decrease that value and your AI should turn much faster.

Thank you Aron. You are the best as always!

I am also noticing this problem with the stock RichAI. If I remove the rigid body, it is very smooth, but once the rigid body is attached (and it is therefore using FixedUpdate) there is noticeable stuttering when the agent is moving. Fixed timestep is set to 0.02.

I don’t remember having this issue prior to upgrading to 4.X (currently 4.1.4) of the project. (Unity 5.6.3)

@MH6

Do you think you could show me a video of this issue? Videos usually help a lot in debugging issues like these.