why delta in _process() and _physics_process() different

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

i have been try to print (delta)
in _process(delta) and in _physics process(delta)

the result is in _process(delta); the delta wasn’t stable
it was print something like this:
0.003967
0.011612
0.015788
0.016176
0.016675
0.016477
0.017501
0.015837
0.016707

but in _physics process(delta) is stable:
0.016667
0.016667
0.016667
0.016667
0.016667
0.016667

why is that different ?

by the way the fps is same 60 fps for both of them
using
Project>General>Debug>Settings>Stdout>PrintFps>On

oh and also, is there any relation between delta and fps ?

(english isn’t my native languange, hope this grammar right)

this is in godot version 3.0.6

:bust_in_silhouette: Reply From: SIsilicon

_process is a function called on every idle frame.
While _physics_process is a function called on every physics frame.

I need to explain this better.
According to the official Godot docs, _process is called every frame in the main game loop as fast as possible. This would explain the inconsistent delta variable. _physics_process on the other hand is called in the physics processing part of the main loop; which would mean a constant delta.

To answer your question about the relation between delta and fps, technically yes. Fps is the amount of frames drawn every second, which can be directly translated into the delta of _process. delta there is usually the amount of time it took for the last frame to be processed. Hope I’m not mistaken.

Correct.
For example, delta can be used if you want to do stuff in given time for everyone, without worrying if one is playing on 300 FPS and someone else on 30 FPS. Without delta, 300FPS player would do stuff way faster.

Oen44 | 2018-11-18 17:40

nice!, thank you, this help understand more

ruruarchy | 2018-11-20 13:04