Discuss Scratch

-Zyntronic-
Scratcher
72 posts

Please let 'deltaTime' be a feature.

I would really like it if Scratch added something called ‘deltaTime’. It's extremely used in C# and very useful. What it does is that no matter what framerate or slow your device is, whatever loop you multiply it by, it will stay constant which is great for anti-jittery code. This request isn't too bizzare so i hope this makes the cut. For more information on how it works, go to YouTube and see the uses of Time.deltaTime…
-Valtren-
Scratcher
1000+ posts

Please let 'deltaTime' be a feature.

I think what you're trying to say is make scratch run the same regardless of framerate
semi support, while I would like to play chirpy reverie in 250 fps existing FPSI projects will no longer be special
now for actual delta time there are workarounds but they're hard and the only things on scratch to have a 100% guarantee that they will not work outside of their example projects
IndexErrorException
Scratcher
500+ posts

Please let 'deltaTime' be a feature.

You can do this already by making a main loop where you do all the stuff you want per frame than puting a reset timer block at the top and setting a deltaTime variable to the timer. This way the timer will always be the frameTime which than you can do FPS = 1 / frameTime. I do this alot so when I use turbowarp at 240 fps I don't zoom around.

See https://scratch-mit-edu.ezproxyberklee.flo.org/projects/650823521/ go to the laser sprite and look at the forever loop. I multiply a constant by the dt(deltaTime) and that means no matter my frame rate, it will always change by the constant every second.

Last edited by IndexErrorException (Aug. 6, 2022 16:17:52)

pythonicKI
Scratcher
100+ posts

Please let 'deltaTime' be a feature.

to get deltatime for projects with no “move” blocks etc (blocks that run and take up time), you basically have to use calculus (the deltatime might even be random idk)

like this:

forever
change [myvar v] by (1)
end

delta time is like 0.00001 or something like that. You can't use timer since it's not that accurate and just gives you 0.

the feature would be very nice :)

Powered by DjangoBB