+5 votes

Other than the fact that func _integrate_forces() deals only with rigidbodies and func _physics_process(delta) deals with kinematic bodies as well, I don't understand when I should use integrate_forces. What is it's purpose and when should I use it?

thanks. :)

in Engine by (391 points)

1 Answer

+6 votes
Best answer

_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

by (22,067 points)
selected by

thanks, that will be helpful in future development!

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.