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?