Can _physics_process and integrate_forces work together?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By blockchan

So how does integrate_forces work?

Does it override _physics_process?
Do they clash when both are called?

Which function is called first?

I’m experimenting with physics and I noticed that sometimes things work only in _physics_process, while integrate_forces ends up behaving weird.

When both are called in the same script it seems to have random consequences, sometimes it’s OK and sometimes not

:bust_in_silhouette: Reply From: fractile

I think you can use both. It depends more on what you do in them.

If you have code that just needs to be executed at constant time step (based on physics_fps), you should use put it in _physics_process(). _integrate_forces() should be used when you need access to PhysicsDirectBodyState for directly changing properties of a body.