+1 vote

I've got a stamina bar, and passive regen for this bar, the speed of restoring is bounded to the process function, and on my PC it work fine, but when I send my project to my other PC and try to launch them there, the speed of regeneration is way too fast, therefore I need to understand, how to make process work same way on all PC's.
Otherwise, I wanna find an alternative solution to this problem, If i only can use something else that just a process() function.
Thanks in advance.

Godot version v3.3.4.stable.official.
in Engine by (63 points)

Maybe this article from the official documentation will shed some light on using the _process() function?

2 Answers

+1 vote
Best answer

if I may add some complement to the previous answer, delta represent the time difference (time delta) between this frame and the precedent one.

As process execute as fast as possible for the PC (depending on its CPU processing power) the rate of execution between a PC and another (or even on the same computer but in different situations) may vary.

So when you multiply a speed_factor by delta in a _process or _physic_process callback, the speed_factor is now a unit / second

for exemple, position = transform.x * 200 * delta in a 2D game will move the transform forward by 200 pixels per second

Note: _physic_process has a stable delta which initialy is 1 / 60 (to match 60FPS) however, this can be configured in the "Project" menu

Hope you better understand why your code runs differently using delta or not ;)

by (167 points)
selected by
+1 vote

What you need to do is use delta. There is a good training resource here https://godottutorials.com/courses/godot-basics-series/godot-basics-tutorial-15/

Fundamentally you multiply a given value by delta to provide the final speed. Delta is going to be bound to how fast the PC is working so it will ensure that each PC will work at a reliable rate.

by (3,321 points)
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.