![]() You see, even when using the song position variable for all things that sync, there still needs to be a reference point that you want to check the song position with. (Game design tip: have as many things respond to the beat as possible! Preferably everything!)īut even then, there is something more subtle that you need to pay attention to – and this is what I struggled with at first. If you use some sort of elapsed-time function, it’s still not going to be accurate enough, and if the song skips for whatever reason everything will get thrown off. in the Update function), an inconsistent FPS is gonna throw the whole thing off. If you use a timer that increments every frame (e.g. Every object that needs to be in sync should do so using only the song position, and NOT anything else. This was used in my game to slow all the songs down 20% because I only realised after composing the music that it was too difficult.Īnyway, now that we have set up our Conductor, time to take care of the objects that need to sync to it!Ģ. By incorporating it into my song position variable, I can change the playback speed and still keep everything in sync. Songposition = (float)(AudioSettings.dspTime – dsptimesong) * song.pitch – offset Īside: the song.pitch is an inbuilt variable in Unity that gives the speed the song is playing at. What I do is, in the same frame that I play the song, I record the dspTime at that moment, so then my song position variable is set on every frame as follows: ![]() This varies from engine to engine, but in Unity for example, the variable to use is AudioSettings.dspTime. Songposition, a variable that should be set directly from the corresponding variable on the Audio object. Offset, always important due to the fact that MP3s always have a teeny gap at the very beginning, no matter what you do, which is used for metadata (artist name, song name, etc) Some are specific to my game, but the general ones that I always have areĬrotchet, which gives the time duration of a beat, calculated from the bpm The above are the variables in the Conductor class. ![]() In this game for example, the Conductor has a variable called songposition which is pretty much the cornerstone of everything in the game. It should have an easy function/variable that gives the song position, to be used by everything that needs to be synced to the beat. In a rhythm game, have a class that is used solely for keeping the beat. Here's the original post! (with diagrams and videos)īut here is a slightly abridged text-only version of the post.ġ. Also, interested in what language you're using with that rhythm game :) ) FWIW, song position works perfectly fine on a rhythm game I released on Android. (Please correct me if I'm wrong Amir! There might be a really good reason you're using that instead of just checking the song position. I don't really agree with /u/amirrajan 's method because it seems to be a lot more trouble than it's worth (crossfades?!?!), and also it seems to work by actually adjusting the music to match the gameplay (by doing the crossfading stuff), when it really should be the other way round for a rhythm game. Copy pasted from a post I made two years ago.
0 Comments
Leave a Reply. |