Godot Version
4.4
Question
Why, if I freeze a Rigidbody2D, change its position and unfreeze it, does he come back to its position before being frozen? What can I do to fix this problem?
4.4
Why, if I freeze a Rigidbody2D, change its position and unfreeze it, does he come back to its position before being frozen? What can I do to fix this problem?
You should only change the position of the RB directly within the _integrate_forces() method.
Thank you!
I didn’t know this method, so now I’m going to learn how to use it.
Should I use this method every time I want to change the rigidbody’s position/velocity?
If you need to reposition the RB’s transform or other physics parameters directly, you should do it from within the _integrate_forces() function, yes.
Quote from the docs:
Note: Changing the 2D transform or linear_velocity of a RigidBody2D very often may lead to some unpredictable behaviors. If you need to directly affect the body, prefer _integrate_forces() as it allows you to directly access the physics state.
Thank you!
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.