Search Unity

Impossible to do a rhythm game with Unity due to latency?

Discussion in 'iOS and tvOS' started by Ninjagorilla, Sep 27, 2011.

Thread Status:
Not open for further replies.
  1. Ninjagorilla

    Ninjagorilla

    Joined:
    Dec 6, 2010
    Posts:
    6
    DISCLAIMER! I'm not a tech guy, just an artist.

    Lately, I've been thinking about designing a rhythm game. But my experience from Unity is that, frankly, it's not very good at responsive audio things. We've experienced latency in all of our games on iOS - For some it might not be noticable, but it would definately be in a rhythm game (as it would be unplayable)

    I'm talking about latencies way over milliseconds - around 0.1 seconds or even more. Yes, we've checked all the boxes (best latency, etc), and, yup, I'm talking about uncompressed sounds.

    So my basic question is - Have anyone ever made a working rhythm game with Unity? And more importantly - Is it even possible? Would it be possible to make a game in which you have to tap the screen in rhythm to a beat, and produce a sound with as good as no latency?
     
    Last edited: Sep 27, 2011
  2. handsomePATT

    handsomePATT

    Joined:
    Nov 30, 2010
    Posts:
    574
    look up Guitar Unity on the asset store
     
  3. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    It's perfectly possible, I'm doing a music app.
     
  4. Ninjagorilla

    Ninjagorilla

    Joined:
    Dec 6, 2010
    Posts:
    6
    Care to share any tricks?
    Are you doing "tap" on beats?
    We tried a solution with delayplay, but it's still out of sync on device.

    Again, I'm not the coder :)
     
  5. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    You just need to:

    1. all samples are set to decompress on load
    2. in audio project settings you use best latency option
    3. by default, audio is synched to fixedupdate, not update. You can change that behaviour (look in docs) or set fixedupdate hz to say, 200, meaning regardless of rendering, you're using a very fast polled and accurate discrete timer for audio. Faster is better because of whatever else is happening in the system. People will shoot this down, but I guarantee they've not tried it out. They're going by theory, not practise.
     
  6. sinetwo

    sinetwo

    Joined:
    Mar 23, 2015
    Posts:
    5
    Hi Hippocoder,

    I'm currently using waitforseconds and using Time.time to compare against my intended interval to have a metronome going. This ensures that (in theory) the next 'beep' compensates for any lag from frames using a coroutine.

    Do you know of any other methods I should look into to get an exact timed metronome please?

    Thanks,
    Kal
     
  7. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    I'm sorry but this post is from 2011, so I've locked the tread. Please make a new one as Unity's audio engine is probably changed quite a bit :S
     
Thread Status:
Not open for further replies.