# delta time in _physics_process vs _process

Attention Topic was automatically imported from the old Question2Answer platform.

I was trying to add 10 to the value of a progressbar every second in order to hit 100 every 10 seconds. In order for the progressbar to look smooth I was using:

func _process(delta):
ProgressBar.value += delta*10

With this method filling the bar took almost 20 seconds but using this second method with a useless variable inbetween speeds up the process filling the bar in 10 seconds.

var value
func _process(delta)
value += delta *10
ProgressBar.value = value

Then I realised that this problem doesnt occur in _physics_process and I can use the first method and reach 100 in 10 seconds.

For what I understand the difference between process and physic_process is that _process is computed as fast as possible every frame while physic_process is computed at regular times so it always has the same delta time. I read that the delta time is not very precise but I didn’t expect for this function to take almost twice as long in _process than in physic_process

So am I missing something? is this a bug?

you probably have a low fps on that project oh wait nvm

Ultra8Gaming | 2021-03-30 08:46

I also encounter it but in my bullet. I tried to not multiply the delta to my speed and it is fast. But by the time I try to multiply it, it become slower

Mrpaolosarino | 2021-04-01 13:18

Try set “step” in ProgressBar to 0 (or something very very small)

If you have a very high FPS, delta becomes very small. The standard-value for “step” is 0.01. If 10.0 * delta < 0.01 you will have problems.

Thats the only problem is can find there, because you first snippet of code is correct.

whiteshampoo | 2021-04-05 07:42

You are not missing anything, its just how it works. _process delta is the time between frames of the main process, in other words, this is calculated as fast as possible unless your game’s framerate is locked. if you pc can run your game at lets sas 200 FPS, it will! And then this delta value will be veeery low, it took so long because you were multiplying 10 with a veeery small number.

_physics_process delta is the time between frames in the physics process, this is fixed and will always be the same.

Anyways to do what you’re trying to do, i’d use a Timer node with a very low wait time (Let’s say 0.1, but can go even lower), “One shot” disabled and connect the Timeout() signal.

Then in the Timeout() signal:

ProgressBar.value += 1

(Using 1 because that would make it 100 every 10 seconds, this will have to be tweaked if you use different wait times on the timer)

_physics_process delta is the time between frames in the physics process, this is fixed and will always be the same.

Only if your game does not lag. If you try to do too much between 2 (physics-)frames, delta will go up.

whiteshampoo | 2021-04-05 07:34