Making a music Game, how to sync sound?

Hey guys,

I’m just getting started with Unity and I wanted to try out an idea I had for a long time now.

It’s basically a music game like guitar hero and similar. Now I created some blocks that will slide down a plane (floor) and when they hit a certain bar, they will play a sound.

For example for an electro song, I have set up a spawner, that spawns one “kick” every 0.5 seconds (which is equal to 120bpm), that will travel down that plane until it hits the bar and plays a “kick”.

Now my problem is, that this kick is very inconsistent. It’s not played in a consistent measure. Sometimes it’s a bit too early, sometimes a bit too late. I guess it has to do with the spawner not really spawning on exact times, but that’s just my assumption.

How can I fix this?

I have attached my project so you may try it out yourself to see what I mean.

Much love

2146618–141577–BeatInvaders.rar (270 KB)

Games like Guitar Hero and Rock Band don’t actually synthesize the music they’re playing. They just play a digitized recording of it, and sync the animation to that.

You could do this by watching the timeSamples property of your AudioSource (which is the component that plays sounds in Unity).

Thank you very much! :slight_smile:

Check out this video. From memory he talks a lot about audio and the very issues you are dealing with.

1 Like