0 votes

Hello! I've been using Godot for quite a while, but I have a beginner question still:

I know that _process() is called every frame while _physics_process() is called every physics frame, which is determined by "Physics Fps" property.

But the thing is: I've noticed that my character moves more smoothly when I put the movement code inside _process() rather than _physics_process()...

Is there any downsides on doing that?

Godot version 3.4.4
in Engine by (94 points)

_process() is called as often as the CPU speed allows, whereas _physics_process() is always called at a fixed rate which may not be as often as when _process() is called, which may explain why it's smoother.

Ideally you want to put any processing that requires the physics values to be correct in the _physics_process() call.

Thanks for the answer! I will be using _process() for now, as I don't see any downsides.

1 Answer

0 votes

Your character moves smoothly in _process() because calculations are made at the frame rate the game is playing at.
Where things start to break is when someone is not playing at the frame rate you intended (As a test, limit your FPS in the engine, you'll see what I mean).
With slower fps, you'd get slower calculations,
With higher fps, you'd get calculations so fast your physics would be liable to break (think GTA SA with uncapped frame limiter).
That's why you have _physics_process() to help when you need consistent results irrespective of frame rate.
But a problem arises when your physics fps doesn't match your game fps, you get jitters and stutters, hence the movement does not appear smooth, and increasing the physics FPS doesn't really solve that issue. To combat that, Physics interpolation was introduced in Godot 3.5. It helps eliminate jitter and stutter

by (64 points)

We can use delta parameter to solve these FPS issues in both _process() and _physics_process(), and as far as I've seen, I don't really see an issue with using _process() (since I always multiply physics calculations with delta).

Yes, that's true to an extent. You won't notice any problems if your frame rate is consistently above the physics frame rate.
Where you'll notice an issue is at lower frame rates. The _process() function is generally called after physics calculations have taken place, so anything physics related would jitter if the frame rate is low enough and you could experience clipping, unregistered collisions, stuff like that.
Granted, you can alleviate that by increasing the physics fps, but that's more strain on hardware, and at that point, you may as well have put the code in physics process.
Either way it all boils down to what's best for your project.

Ohhh I didn't knew that. I will do some testing with my project. Thanks for the answer!

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.