What is the point of MovePosition()?
In the docs for Rigidbody.MovePosition it says that MovePosition() is supposed to be used for kinematic rigidbodies, and it moves kinematic rigidbody smoothly if interpolation is enabled.
However even with interpolation enabled my objects move with lots of jitter. It seems that kinematic rigidbodies ignore interpolation settings regardless of whether you use MovePosition() or transform.position.
But then.. what does MovePosition() do that transform.position doesn't?
Answer by Edy · Sep 10, 2021 at 03:51 PM
"what does MovePosition() do that transform.position doesn't?"
- computes the Rigidbody's velocity internally based on the resulting motion.
- applies the correct physics effects in the other non-kinematic rigidbodies.
- interpolates the resulting positions based on the Interpolate setting of the rigidbody.
For the above to work correctly MovePosition() must be called once within each FixedUpdate() with a "stream" of continuous positions.
The following will cause wrong effects in the rigidbody motion:
- Calling MovePosition() from Update().
- Feeding the same position in two or more consecutive calls. That will "stop" the motion and the internal velocity will be calculated as zero that physics frame.
Thank you! And do you mean kinematic rigidbodies also do interpolation? So they can move smoothly too?
Yes. If kinematic bodies are moved with MovePosition() as described, then the Interpolate setting will be properly applied.
Doesn't quite seem to be the case, but thanks, i'll try again
Your answer
Follow this Question
Related Questions
Making a rigidbody "immune" to reacting with another specific rigidbody? 0 Answers
rigidbody iskinematic issue 1 Answer
how to prevent a kinematic rigidbody from going through static colliders 0 Answers
Freezing an object and keeping it's velocity 1 Answer
How to check if kinematic rigidbody is overlapping anything in the scene? 0 Answers