playMaker

Author Topic: how to wait precise in milliseconds  (Read 3362 times)

MS80

  • Junior Playmaker
  • **
  • Posts: 64
how to wait precise in milliseconds
« on: July 18, 2016, 12:18:28 PM »
I have a problem with the regular wait action, maybe I'm doing something wrong, but it seems to me that "wait" is very imprecise if it comes to very short times, f.e. 0.005 sec! I feels like there is a limit for the wait action, like around 0,1 seconds, it does not care of smaller values.

I have a sensor input and want to capture values in intervals, f.e. every 5 millisecond (=0.005 seconds) to calculate a stabilized average value, but this is not possible with wait action. To capture input per frame (with next frame) is no option, this is a bit too slow (@60fps = 0.016 second) I need very short periods.

I have no idea how to get more precise wait periods, any help is welcome!
« Last Edit: July 18, 2016, 05:45:07 PM by MS80 »

mdotstrange

  • Hero Member
  • *****
  • Posts: 555
    • Can't code? Who cares! Make games anyway!
Re: how to wait precise in milliseconds
« Reply #1 on: July 18, 2016, 05:19:08 PM »
You might want to check out the "next frame event advance" on ecosystem- it allows you to wait a specified number of frames-
Indie game dev and instructor at the Strange School. Learn Playmaker at the Strange School!

MS80

  • Junior Playmaker
  • **
  • Posts: 64
Re: how to wait precise in milliseconds
« Reply #2 on: July 18, 2016, 05:35:53 PM »
Thanks mdotstrange, did not know "next frame event advance", unfortunately I could not find the action in the ecosystem. Ecosystem browser seems to be a bit buggy at the moment, I often get "search error: 500 internal server error".

But I doubt it will help in my situation...

EDIT: I found the answer  :D (http://hutonggames.com/playmakerforum/index.php?topic=11600.0 in the post by ManicMinerUK)

"its probably worth bearing in mind that by default, 0.02 seconds is the duration of a frame in Unity, so if you want delays shorter than that, you will need to go to the project settings/Time and shorten the default timestep.

This might be why you are having problems with your waits as well?"


Unity's timestep is set to 0.02 by default, if I use smaller values like 0.005 a frame will only take 5ms instead of 20!
« Last Edit: July 18, 2016, 06:13:12 PM by MS80 »

Zeldag

  • Full Member
  • ***
  • Posts: 198
Re: how to wait precise in milliseconds
« Reply #3 on: July 18, 2016, 11:04:44 PM »
Hi,

Congratulations on solving your issue!

Just thought I would add this, if you ever cannot get an action because ecosystem is playing up- then usually google will find it.

Here is 'next frame advanced' (hopefully as up to date as the ecosystem one (edit to add: it was posted on in April 2016 so probably should be up to date :D )):

https://snipt.net/dudebxl/nextframeeventadvance/

(Also, Im not moaning about using the wrong forum or anything, but I think your post may have received more attention in the help forum. (Just personally I dont think I visit here as often as there)).

Good luck with it!
« Last Edit: July 18, 2016, 11:06:21 PM by Zeldag »