How to properly move Rigidbody2d in kinematic mode?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Flonka


I want to switch the behaviour of a Rigidbody2d node from kinematic to rigid and vice versa. Currently I am trying out 3.1 beta2.

What confuses me however, is how to properly move the rigidbody, when in kinematic mode. What i find is, that i should be altering the position directly, which is what is stated one should not do, reading from the documentation.

After debugging the behavior of the body. I found that It looks like, once in kinematic mode, the body’s state is forced set to sleeping (though can_sleep is false), and the _integrate_forces function is not called. Applying forces or impulse won’t move the body, so altering the position(set_position/set_global_position) is all that’s left. And once I do that, integrate is called, the body moves and is interacting with other bodies in the scene.

According to the latest doc, it should behave like the KinematicBody2d, but in the rigidbody class, we don’t have access to the “move_*” functions , which is the recommended way to use that node type.