Stuttering movement even using AILerp

Hi,

I’m having trouble getting smooth movement.

I’m working in 2D with a Grid Graph. In fact you can recreate this on the 2D example.

I’ve got a seeker using the AILerp script.

Scenario 1:
The seeker is in the scene from the start. This has beautiful smooth movement, exactly what I want.

Scenario 2:
I spawn the seeker at some later time (or disable and then re-enable the seeker from scenario 1). The movement is now jittery! It can be fairly subtle but if you’re using a follow camera (as I am) it is very pronounced and looks nasty.

I’ve tried all sorts of things, playing around with the repath rate, trying different node sizes on my graph etc. The lower the repath rate the more pronounced the jitter so it does appear to be happening every time a new path is calculated but it’s so odd that it doesn’t happen if the object was in the scene from the start!

Any help would be much appreciated.

EDIT:
It does seem to be tied to the follow camera actually. Disabling it means the movement does appear much smoother (I thought I’d already ruled out the camera as being the problem but now I’m not so sure).
My follow camera is very simple though, just this in an Update:
transform.position = new Vector3(followTarget.position.x, followTarget.position.y, transform.position.z);

EDIT 2:
Aaaand changing the follow camera to update on LateUpdate instead solves the problem, so it was nothing to do with the pathfinding, sorry! Power of the post :slight_smile: I’ll leave this thread up though in case anyone else has a similar problem.

1 Like

Hi

Great that you managed to solve it.

Yes, putting camera following code in LateUpdate instead of Update is usually a good idea since otherwise your camera may effectively try to follow a point 1 frame behind where the character actually is.