I need rigidbody to move from current position to new position. I tried it using RigidBody.MovePosition, the problem is that the moved object goes throught colliders when there is big difference between current and target position. I am updating it in fixed update.
What is the interpolation setting on the body?
I think you should be set to interpolate, if it’s set to this and extrapolate(and any other one that’s there) this should be a bug according to the docs.
“Rigidbody.MovePosition moves a Rigidbody and complies with the the interpolation settings. When Rigidbody interpolation is enabled, Rigidbody.MovePosition creates a smooth transition between frames.”
To be clear on this subject; Interpolation is just a visual thing, it’s not used in collision detection and only updates the Transform on the GameObject per-frame. The actual body just sits in its new position while the Transform interpolates from its last position to the new one.
It’s more likely related to the fact that the Rigidbody is set to use discrete collision-detection therefore it’s just tunneling past colliders.
I don’t think this is possible using MovePosition. You’re just forcing the object to move to the target position, then to continue the physics simulation from there.
Reacting to colliders properly require you to move the object using Rigidbody.AddForce and/or Rigidbody.AddForceAtPosition only. Note that these methods allow to specify mass-independent accelerations and velocity deltas. Check out the ForceMode parameter.
I’m facing a similar issue. The docs say “Rigidbody.position allows you to get and set the position of a Rigidbody using the physics engine.” - So I assumed physics interactions are being preserved, but it doesn’t look that way. I’m placing a small cube on top of a large one, using regular gravity. When I move the large cube via Rigidbody.position, the small one stays more or less in place, like it is sliding along the large body’s surface, although I’ve set their material’s friction to 1.