Why doesn't fixedupdate exist?

Hi,
from unity and godot I know the update() function which is called 30/60 times per second and the fixedupdate() function called once a second.
In both engines I use fixedupdate() to move kinematic bodies so that the movement matches with the overall physics simulation.
update() on the other hand is used for any other operation (or even movement of a gameobject without a rigidbody)

I’m wondering why there is only one update() function in defold.
If I move a game object without a collision object component: is it then moved every frame?
On the other hand: If I move a game object with a collision object component is it moved every second but the remaining code of the update loop (including messages and input) every frame?

Which magic happens under the hood? :wink: Or isn’t there any magic?

Thanks for your help
Boris

Everything runs on each frame, so physics is also at 60fps.
If you need a slower update use timer.delay() to call a function periodically.

3 Likes

Thanks Sergey
Though this question is off-topic: Do you know why Unity has the FixedUpdate() method? Why doesn’t Update() handle the physics like Defold does?
Would help me to understand the process better

What we would like to do in Defold is to decouple physics simulation from rendering. It can sometimes make sense to have the rendering happen 60 times per second while the physics simulation happens only 30 times per second or at any other interval for that matter. The problem we’re facing is that we are not able to run the physics in a separate thread on HTML5. We may be able to do this in the future, but for now everything happens in sync in the engine.

3 Likes

:+1:

Hi dear @britzl
Because of long time not using Defold I didn’t know you added fixed_update, I just see this function on default script and after searching I found this topic and after that This update topic as well. The question is: does it work well on HTML5 export in current version?
Thanks in advanced

Yes, it works fine! We are upgrading all our HTML5 games (made with Defold) to use fixed update and everything goes well so far.

4 Likes

We haven’t updated our documentation to include this yet, but it will happen during this week. We also have a few other new additions to the engine which we haven’t documented yet, and we will add all of the new documentation at the same time.

2 Likes

Thanks aglitchman, why do you want to change all your HTML5 games to use fixed update? maybe you want to run physics calculations on lower fps to make better performance? or something about Synchronizing things together? or just to make things seperate to make more control? :thinking:
However I have never had serious problems without fixed update function but it’s nice to see this feature added, I used to use fixed update in unity as well.

Our games use built-in physics, and to simulate the behaviour of fixed update on pre-1.3.1 we had to enable the “vsync” option (note: it works differently on 1.3.1+, i.e. as it’s supposed to) to fix timestep to 0.0167 ms. The benefit was that physics ran predictable. The drawback was that the games ran slower or faster on non-60Hz screens. After migration to 1.3.1+ we finally managed to fix that issue.

4 Likes