Very jerky movement when using FixedUpdate

According to the docs you’re supposed to use FIxedUpdate for doing physics.
I have an animal AI that follows the player. I tried using the FixedUpdate to do rigidBody.MovePosition(..) like the docs says. This just results in completely jerky movements. It’s almost like the rigidBody isn’t moving for about 5-10 frames every now and then, resulting in studdering.
Then I tried using Update instead and the results are much more smoother.

Wondering if I’m doing something wrong.
Rigidbody:
Extrapolate
Collision detection: continuous

Frame rate: 50 FPS
FixedTimeStep: 0.02 (50 FPS)

code:

rigidBody.MovePosition( Vector3.Lerp (rigidBody.position, playerPosition, movementSpeed * Time.deltaTime);
}

Also, when running the game for a while, I kept track of the amount of FixedUpdate calls and Update calls for the script. The results are:

of Fixed update calls: 5902

of Update calls: 5848

Does anyone have advice on this?
Could I be doing something wrong here?
Is it not really set in stone that fixed update should always be used for moving a rigidbody?

Check to see if your camera-following code is also using FixedUpdate. If your mover is using FixedUpdate (which the physics engine does) and you follow it with a camera driven off Update, then you will get jerky camera following.

2 Likes

I don’t know what playerPosition is, but Kurt made a good observation.
I have an additional observation: The docs state that you want interpolation for MovePosition.
I do not know/think that you require Lerp, either… but you could try either way. :slight_smile:

1 Like

lol I see some likes here… Does that mean that you solved it?