Syncing a Rhythm Game

Hey all. As an exercise in expanding my knowledge of Unity, I’ve decided to try to make a small rhythm game. Nothing too complicated. Enemies appear; Press a button on the beat to shoot them. Looking for info on this topic, though, I find pretty much only old knowledge with a range of answers.

So, what’s the current best way to sync a rhythm game? The game is being designed to run in a web browser, and I will probably be using an MP3 for the music, though I might be able to change that if it’s an unsuitable format. If I’ve forgotten to mention anything really important, let me know.

Ended up on page 2. Nobody has any info to share?

http://forum.unity3d.com/threads/58769-Unity-3-Audio-Spectrum-Analysis

Thanks for the info! Just about all of this seems to have to do with measuring the audio spectrum, though. I’m looking for something more like timing events to certain times in an audio file. Measuring the audio is useful, but I’m not sure how I would give the player a good on-screen guide leading up to the beat with that.

1 Like

If you know in advance the times in an audio clip that you want to trigger events, then you can map those relationships in a list of objects associated with an audio clip.

Class would only need two members
EventReference (reference to a method)
Time Or TimeSample

You can use the audiosource time or audiosource timesamples to track where you are in an audioclip that is playing.

You would sort the object list by time/timesamples asc
You would check in update if the current time is more than or equal to the relationship time of the first object in the list associated with the clip that is playing.
If it is, then you would fire the event and remove that relationship object from the list.

Hello , i been working on a rhythm battle game, try the webplayer here: www.tipografico.cl/pelea2 . What i do is map the entire song in adobe Soundbooth pressing the (*) key in the numeric keypad, so its create a marker whit the timecode , then i copy all those markers in a txt file so i can read them with c# and make a float array with all the timecodes. Then with a Coroutine loop the timecode array so instantiate enemies when the time is equal or major to the timecode in the array. I hope this can help you.

1 Like

Wow, that is an interesting method. Any reliable onset beat detection scripts or midi file to event scripts on the Net these days?

Thanks in advance!
@Watapax

I made a rhythm game in Scratch, and I use a variable that is constantly increasing. The notes spawn when the increasing variable is equal to the next value on the beat map, generated by custom blocks.