HTML5 application ignores FPS settings of the project (DEF-2085)(SOLVED)

HTML5 application ignores FPS settings of the project. When HTML5 is used as build target, FPS is always 60 and all animations speeds up proportionally. Other platforms go as set in project settings (30 FPS for example).

What and how are you animating?

Flip-book animation in sprites. But animation itself is not the only problem.
For example, i’m moving some object 3 pixels each frame, using go.set_position(pos). So, 30FPS = 30pixels/sec. and 60FPS = 180 pixels/sec. This is a big difference.

You should not do this. You need to use delta-time from update() to ensure that your game objects move the same number of pixels regardless of update speed:

function update(self, dt)
	local pixels_per_second = 90
	go.set_position(go.get_position() + vmath.vector3(pixels_per_second, 0, 0) * dt)
end
2 Likes

Thank you for the code. I’ll use it.
But what about performance? Games at 30fps can run more smoothly on devices where 60fps games get lags. Game engine will have more time for calculations.
33ms/frame at 30FPS and only 16ms/frame on 60FPS
Also less FPS - less power will consume GPU for calculations, so games at 30FPS are more power efficient. But HTML5 applications built using Defold ignores FPS settings of the project.
I’m trying to make it 30FPS, but i get 60 anyway :slight_smile:

Could you check if you have variable_dt checked in game.project? If it is checked it will completely disregard whatever value you have set in update_frequency:

“variable_dt - Check if time step should be measured against actual time or be fixed (set to update_frequency).”

variable_dt is unchecked.

Ok, hmm, I don’t know enough about the HTML5 implementation to figure this out. @sven, any ideas?

I think the update loop for the engine is a bit different on HTML5. Browsers “request” new frames to be rendered instead of us doing it “at our own speed”.
On the other hand I don’t think this should be any major hinderance for us to solve it, so I’ll file a bug for this. Thanks for reporting! :slight_smile:

Good to hear :slight_smile: . Thank you for response.

1 Like

It was fixed in Defold 1.2.115 as DEF-1785

2 Likes