How to make deltatime?

I'm having trouble creating an accurate deltatime variable in Snap.

In Scratch, it's very easy to create deltatime with this code and variables:


when [green flag clicked]
forever {
set (deltatime) to ( (timer) - (FrameBeforeTime) )
set (FrameBeforeTimer) to (timer)

This code gives dt = 0.033 most of the time since Scratch runs at 30 frames per second.

However, in Snap, deltatime equals strange values when running the same code. It usually alternates from deltatime = 0 to deltatime = 0.0999999.

I don't understand why this would happen and if it's even possible to have a proper deltatime in Snap. Is there a way to make deltatime? Thanks.

That's because Snap! rounds timers to 1 decimal place. To make it, you can use:

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.