How to reposition ReigidBody2D?

Godot Version

V.4.3

Question

I want to reposition RigidBody2D without interference woth physics. Meaning even I reposition that it should continue its motion. I have tried to change position directly but it makes rigidbody to float. And I tried it with freeze before and reposition and after un-freeze but it sinks into the StaticBody2d (for floor)

You have to move a RigidBody with physics. There is a workaround, but it makes maintenance harder and is not the wanted behavior as of Godot’s design:

Parent the RigidBody2D to a Node2D and add a script to that, changing the RigidBody2D’s position.

I just want to make animation using this physics. It is easier if I can reposition the body.

To safely teleport a RigidBody2D you need to do it in its RigidBody2D._integrate_forces() function modifying the PhysicsDirectBodyState2D.transform property of the state parameter.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.