Entering a rhythm game

So, Unity does not make many rhythm games on android. I decided to find out why, and program one as an assignment (the basics of it anyway). My most important hurdle is user input. Since we know that the input is based on the frame rate in unity, and the music game (I suppose) would prefer the smallest possible delay between the press of a button and the action.

If we look at the music, from 15 to 20 ms delay, the human ear hears that something is “turned off”.

I heard that Android Unity games run at 30FPS (since 60FPS sucks the battery dry), simple math shows: 1000/30 = 33 ms per frame. Computing in 15 ms, we probably will not notice, we are in 18 ms of a possible disaster. assuming we always achieve this 30FPS at any time.

When I get an input from a user, I can play the sound at that input on the same frame. However, we could disconnect at 18 m.

Now there is a way to get DIRECT controls with the mouse and keyboard, which uses OnGui () instead of Update () to receive keyboard or mouse click events in place. The problem is that the android probably doesn’t work with this (this also doesn’t work for gamepads), and the methods sound completely strange, especially when we try to play sounds from the OnGui () method.

My question is: What would you do and why? Should we just accept the possible 18 ms and suppose we reach 30FPS, or should we look for a reliable way to direct input instead of waiting for an update?

Thanks for any insight you can give me, I have not yet found articles about this that are still useful. -Smiley

EDIT I just did some basic testing with the metronome, working at 100FPS in the editor (which should be 10ms per frame), pressing my space bar on the metronome inside the unity. The results I got were just awful. Pressing quickly: I reach 20 ms to my metronome, but nothing closer. Pressing the rhythm: I had at least 200 ms from the target tick. If I am not confused by this rhythm, this is simply wrong.

I am currently using Debug.Log to retrieve my test data in a log. Can someone please acknowledge me if this could be the reason (causes some long delay? I know that debugging is not optimized), or is this time really bad?

Thanks in advance, -Smiley

+7
android c # unity3d music
source share
2 answers

First, I would like to add a few comments to your comments and analysis:

There is much more to measure the delay between the tactile input and what your eyes perceive.

Probably the largest I see in your tests is the latency between the graphics card and the PC monitor on which you are testing. Many conventional LCD monitors these days have latencies of 15 to 30 ms behind processing . I don’t know how much this applies to mobile screens and hardware, but I would suggest you spend time doing additional tests on your target hardware before making any further conclusions.

To more accurately answer your question:

I would continue to use Unity, but I would continue to explore the best methods to input and feed it back to the player as quickly as possible. In the comments above, @rutter pointed out to you that looks pretty good on this .

I would consider special attention when using FixedUpdate () to separate the frame rate from input processing speed.

I think it’s also worth spending time studying the psychology of perceiving latency. For example, if your game is a kind of Guitar Hero game corresponding to a game song, you can simply take into account the backlog that you know, and take this into account when checking input.

+2
source share

I think that you complicate this too much, and that the accuracy problem is not as bad as you think.

People usually press buttons a little earlier to synchronize what they see and hear.

It also depends a lot on whether you have some kind of scrollable display that they try to match up to ... if the display scrolls smoothly at 30 frames per second (without large transitions), they can still do their timers pretty for sure.

I would suggest that although people can hear when their time is off, their actual time of pressing the buttons at the right time is not so accurate.

Here is another simple solution ... which, it seems to me, is often called a rock band and a guitarist ... In any case, you start playing a note / sound at the right time ... then change it to a broken sound if you find that they missed it or came up with it.

0
source share

All Articles