_physics_process()
is called on every node during the physics processing step of the main loop. You should place code here that needs to be synced to the physics engine.
Because rigid bodies are controlled by the physics engine, you can't just set their properties (such as position, etc) directly, as that would conflict with the physics engine's calculations. When you do need to do something that would "break" physics, you have _integrate_forces()
, where you can directly access and alter the body's physics state.
You can read more about this, along with examples, here: https://docs.godotengine.org/en/stable/tutorials/physics/physics_introduction.html#rigidbody2d