Unity MovePosition

In the Update method, when a moving Rigidbody is set with: rb.MovePosition(rb.position + po * speed * Time.deltaTime), the wall penetration phenomenon can occur at high speeds because, in special cases, it is necessary to respond immediately to the Rigidbody’s movement in Update to synchronize animations. Using rb.MovePosition allows for a quick response, while using rb.velocity in FixedUpdate can result in delays, desynchronization, and jittering issues when interacting with animations. Therefore, while rb.MovePosition is used, it causes another problem: wall penetration. Is it possible to add a second parameter like rb.MovePosition(rb.position + po * speed * Time.deltaTime, [ Block through = false ]) to prevent wall penetration? This feature is greatly needed. Thank you.

If you have a solution, don’t wait for the internet’s approval. Ship It! and move on to the next task.

I imagine the penetration is happening because you’re moving a rigidbody outside the physics loop, so it’s not handling de-penetration at that point in time, and no parameter is going to fix that.

Stop polluting the forums.

The 3D physics version of MovePosition is meant to be used with kinematic rigidbodies and so it doesn’t block movement. Although at low speeds it can seem to be blocking but really it’s just depenetrating an object after the move. If you move the rigidbody quickly then it can pass through other objects unhindered.

Ideally you should use AddForce for moving a non kinematic rigidbody. And if you need more responsive movement then you could try reducing the mass of the rigidbody or use ForceMode.VelocityChange.