playMaker

Author Topic: Precise Timer?  (Read 4719 times)

kiko

  • Playmaker Newbie
  • *
  • Posts: 17
Precise Timer?
« on: February 08, 2014, 06:38:27 PM »
Hi, I'm making a rhythm game that relies on precise timing that is independent of framerate or CPU load.

I've tried using playmaker's Wait function, but it's very inconsistent.

Using "System.Threading.Thread.Sleep();" in c# works, but it also pauses the entire game along with it.

ANy ideas?

escpodgames

  • Hero Member
  • *****
  • Posts: 687
    • Assets
Re: Precise Timer?
« Reply #1 on: February 08, 2014, 06:51:16 PM »
Did you tick "Realtime"?

Otherwise you could use the Get time info action OR the Get system time action (not sure if they are custom or shipped with playmaker) would have to change the default formatting.
« Last Edit: February 08, 2014, 06:57:26 PM by LampRabbit »

kiko

  • Playmaker Newbie
  • *
  • Posts: 17
Re: Precise Timer?
« Reply #2 on: February 08, 2014, 09:15:21 PM »
Did more digging by looking up how to make a metronome in Unity, and found these links:

http://forum.unity3d.com/threads/198097-Can-you-have-sounds-only-play-in-sync-with-music-Effectively-quantizing-them

http://docs.unity3d.com/Documentation/ScriptReference/AudioSettings-dspTime.html

http://pastebin.com/MJRm2DHr

So basically Audio runs on a completely separate timer from everything else (AudioSettings.dspTime as opposed to everything else using the Time class.) So in order to sync with audio, you need to time things to that dspTime value... which Playmaker doesn't have any support for afaik.

If someone wants to be SUPER EXTRA COOL, and figure out how I can send an event every X milliseconds using dspTime, then I'll be your best friend forever  ;D
« Last Edit: February 08, 2014, 09:32:32 PM by kiko »

parallel

  • Full Member
  • ***
  • Posts: 155
Re: Precise Timer?
« Reply #3 on: February 08, 2014, 10:13:12 PM »
Not sure if the metronome is exactly the same as a sequencer you're looking for, but I tried picking Jean's brain on that before, here:
http://hutonggames.com/playmakerforum/index.php?topic=4257.msg25305#msg25305

I think the guys who were successful with making rhythm tight trackers (over on unity forums) solved it in similar ways, perhaps it was something ala equally sized samples?, as I think they found out that there was no such thing as tight millisecond control of audio to be had. At least that's how I recall it portrayed when looking into it.

kiko

  • Playmaker Newbie
  • *
  • Posts: 17
Re: Precise Timer?
« Reply #4 on: February 09, 2014, 02:17:11 AM »
Parallel, thank you for that link! Led me to this:

http://forum.unity3d.com/threads/78003-Audio-stepsequencer-and-they-said-it-couldnt-be-done!

My plan is to take this code, and then make it so it broadcasts a "beat" global event with accurate timing.

Failing that, I'll try chopping the music into many 1-measure files, and then I'll broadcast the event every time I play the next file in sequence. (Using clockstone's pooled audio tool for playback btw).

Going to take me a while as I'm a novice coder, but I'll try my best. Any help or hints would be appreciated :)
« Last Edit: February 09, 2014, 02:53:33 AM by kiko »