what is the best practice to call a function after a known time interval?
I tried setTimeout but apparently it does not work
setTimeout.wick (2.3 KB)
in default, set some var to 0. in update, keep incrementing that by 1. when the time is right (when enough frames passed by to increase the var to the right place) then you can run something.
ok. thankyou awc
this do work but it depends on framerate.
it should be ok on 99% of cases but should the framerate drop the delay also stretches
i wondered if it was possible to use functions depending on time interval like setTimeOut, setInterval or similar.
I just wanted to add that it is possible to use setTimeout…but for some reason when I tried using it in your project, with the rotation example, it wasn’t working for me…I’ll take a closer look at it and see what I can do. But to just have a working example of setTimeout, here’s one:
setTimeoutPrint.wick (2.0 KB)
Click the print button, and after 3 seconds, you should see the print dialogue pop up.
I basically tried to apply this code to rotate the quad shape, but then it didn’t work in that case…I don’t know why at the moment
you can use one of the date and time functions in javascript to measure time instead of framerate. i did like 10 seconds of research so you probably need more info, but Date().getTime() should help you.
@bluecake
yup timeoutPrint works
will try to understand why. ty
@awc95014
ty. i’ll look into that too.
I would use Date.now()
. They do the same thing
Can’t you just use " Date()
" to know the time?
text.setText(Date());
I wrote Date()
in the console are it returned this:
"Wed Nov 04 2020 14:24:21 GMT-#####################"
Wait does my time zone also count as personal information?
I would avoid sharing timezone
I forgot a console existed in Wick (I still use 1.18).
When I write “Date.now();
” I get some weird numbers… do you know what these numbers represent?
The current millisecond from the unix epoch (Janurary 1, 1970 at 12:00 AM).
Time can get confusing
Thanks for letting me know, it makes more sense
I used the Chrome dev console. I think you’re on a school computer, and my school computer doesn’t allow me access to the console, so I think it would be safe to assume that you can’t access the console.
I can access the console, I’ve just never used consoles before