You can’t teleport (aka change the position
) of a RigidBody2D
like that because the physics system won’t be synced and it will cause issues.
You’ll need to do it in RigidBody2D._integrate_forces()
and modify the state.transform.origin
accordingly. You can check this answer How can I change a node's position during physics interpolation without fast moving effect? - #2 by mrcdk as to how to do it