Unity already decouples gameplay from framerate. If you remember to always use Time.deltaTime in your Update-functions, the actual graphics framerate should not affect gameplay speed. So when you start the game and the audio track at the same time, they should stay synchronized.
Regarding designing levels around music, there are two approaches:
- The manual approach. Meticulously hand-craft levels around specific audio tracks. Having the original sheets music at hand can help, but it's also possible to do it just by ear.
The manual approach. Meticulously hand-craft levels around specific audio tracks. Having the original sheets music at hand can help, but it's also possible to do it just by ear.
- The procedural approach. Use audio analysis algorithms to auto-generate levels around audio tracks. The most simple is to just look for volume spikes. That should already allow you to identify drum beats in many songs and spawn obstacles accordingly. A step further is detecting volume shifts separately in different frequency spectrums. This makes beat detection more reliable and allows you to spawn different obstacles for different pitches. But that's still just scratching the surface. Audio analysis is a very wide and interesting field. People wrote a lot of scientific literature about it.
The procedural approach. Use audio analysis algorithms to auto-generate levels around audio tracks. The most simple is to just look for volume spikes. That should already allow you to identify drum beats in many songs and spawn obstacles accordingly. A step further is detecting volume shifts separately in different frequency spectrums. This makes beat detection more reliable and allows you to spawn different obstacles for different pitches. But that's still just scratching the surface. Audio analysis is a very wide and interesting field. People wrote a lot of scientific literature about it.
How deep you need to dive into this field depends on how ambitioned you are. Some games are satisfied with just detecting the beats and randomly-generate all the rest of the level design(Crypt of the Necrodancer). Others try to put as many aspects of level design under the control of the audio as they can (Audiosurf).
How deep you need to dive into this field depends on how ambitioned you are. Some games are satisfied with just detecting the beats and randomly-generate all the rest of the level design(Crypt of the Necrodancer). Others try to put as many aspects of level design under the control of the audio as they can (Audiosurf).
Many rhythm games use a hybrid approach. You generate a first draft of the level using a generator and then tweak it by hand to make it more playable.