Thank you. This is the best method iv seen for making a rhythm game especially since you have full control over the midi file. The Ui stuff could do with some work but a really great starting point for any project :)
Hey, amazing tutorial! I've been able to create a bare-bones rhythm game following your code and setup. I've also made some minor modifications like adding an outline for the notes when they're within the tap window. However, I'm having some trouble with spawning the first notes. For some reason, I find that the first few notes are being bunched up together. My guess is that the initial spawn is already too late for some notes in my chart, so they end up spawning all together and hitting noteTapY at around the first second, regardless of their note timestamp. I'm still working this out, but would you know a way to somehow adjust the initial position of the first notes such that they hit noteTapY at their expected time? EDIT: I've found that the issue was with the notes' timeInstantiated variable. Ideally, timeInstantiated would be equal to (assignedTime - noteTime), such that the note would be instantiated at the top of the screen so it would travel across (for the duration of noteTime) and reach the target at exactly assignedTime. If the assignedTime is less than noteTime, then that would mean timeInstantiated should be negative, which is impossible since timeInstantiated is set from the audio source time (minimum 0). I've worked around this by setting (timeInstantiated = assignedTime - noteTime) at the notes' Start method, so timeInstantiated wouldn't be set necessarily to the time it was instantiated, but rather the time we want it instantiated for it to hit the tap location after noteTime has passed. Not sure if this would impact something else in the code, but it works. Haha.
Life saver, this fixed the issue for songs that start early and also for higher note times. The issue I'm running into now (At least for my preference) is that the notes spawn in the middle of the screen. I prefer if the notes spawned outside the screen view and the song started after the songDelayInSeconds variable from songmanager script.
@LyingTurkey thats unfortunate also i whoukd like to uses something like .osb format from osu or .sm and .ssc from stepmania for compatibity reason since theres not much thing we can use in midi(unless you go full length into .bms rabbit hole from Bemani)
hey i dont know if youre still active but im getting an issue where unity cant actually find the midi file. its trying to use a path that doesnt work. for example if the actual path is D:\X\Y\Z, unity is trying to use D:\X\Z. i am not a coder in any way shape or form, im using this video for my college project which is arts focused, but i need to do all the development too
The Unity game engine always has three directions. In a 2D template, this is just not shown because the scene view is in 2D mode and the camera is orthographic. The third z-axis is always there though.
Great tutorial for a base of a rhythm game! I'm trying to do one on mobile, but how would you implement different types of notes such as long note or flick note?
Thank you so much for this great tutorial! I participated in the rhythm jam and made a pretty decent game thanks to you! I also uploaded a video on my channel about it if you're interested :)
Idk if you're still answering questions, but my application of this code causes the note times to be a higher tempo than the actual song. My test shows the note being played nearly 2x speed compared to the song. Do you have any idea why this could be? I am using notes from multiple octaves that have chords [so some overlap of notes].
So it is in time now I think since I multiplied the time conversion by 4 [idk why that works] but now I am noticing that it is totally skipping over certain notes in the song. My hypothesis is that it is notes on the same key overlapping somehow.
For over a decade now I've been calling these files "mid-ee" files and am a musician - I am afraid to find out if I have been wrong for so long now that I am questioning my pronunciation.
Hello SkyyanSam, thank you very much about this tutorial, I have a question about this video in 3:05 , you press the button to record, I want to know that the track automatically recorded by the software ,or you press keys on your keyboard while recording? I am sorry that I know nothing about music...thank you and looking forward to your reply...
How do you know where to place the white line? is there math behind when the beat is due and where to place the line or is it just trial and error adjusting the line according to the audio?
Amazing tutorial! I used this to upgrade my charting system in my rhythm game. I do have one question, though. How could I add long notes? I already have long note prefabs set up and everything. I just don't know how to go about programming it in the script.
Glad you found the tutorial helpful. I've been working on a footnote to this tutorial on implementing hold notes but other circumstances have been slowing me down. If you wanted to check if a note is a hold note you could get note.Length and use TimeSpan to convert it to metric format (seconds). If the length in metric format is greater than a certain value, then its a hold note, else it is a regular note.
Hey, so I made a rhythm game with similar functions for the buttons, but right now I am trying to figure out how to let the player choose their own key binds. If you could lead me in the right direction, I would greatly appreciate it.
I just did this in my game not long ago, I will say it was a ridiculously stupid endeavor that I somehow was able to get working! However my code is definitely not the best... I wanted three different control schemes rather than a keybinding method. There are tons of different tutorials out there for keybindings in unity, but for my set control schemes route I set up three enums, then had 3 buttons in a control settings screen set to select between those schemes. and the selected schemes read off three different dictionaries of keycodes... It is a nasty set up that i don't recommend, but until someone recommends something better I'm stickin with it lmaoooo. I wish you luck
Thank you for the tutorial, really helpful. However, I found out the notes movement is very choppy, is there any fix for that? Also, how do you make a long notes? Thanks
This is great for more intermediate unity devs but is there a tutorial that uses drywetmidi for beginners does anyone know? sorry this probably isnt the place to ask! I enjoyed watching this though!
Now I'm learning from this video. Great tutorial!! Could you give me some advice? If I wanna change the starting direction of the notes from Y (Up) to X (Right) or -Y (Down). What should I do? (I never made a game ;)) Thank you, sir.
If you want the notes to appear coming from the bottom instead of the top just make sure TapY is greater than spawnY. You could just switch the values of tapY and spawnY and in theory everything should work since the position formula is based on leaping. For changing it so the notes come from the right, you could edit Note.GetPosition() and switch position.y and position.x. What you could do is something like this var temp = pos.x; pos.x = pos.y; pos.y = temp; You could also directly edit the vector in Note.GetPosition(). Hoped this helped! :)
Thats odd since the notes use a lerp function that takes in the time from SongManager.GetAudioSourceTime() Maybe try and print SongManager.GetAudioSourceTime() in update and see if there is/isnt a difference
Hi, I followed along your tutorial, but the project only works with your example MIDI file and not anything I made. My MIDI is also made with LMMS, and the only difference I can think of is that I used only two notes (A and B) for simplicity. I know this is a broad question, but do you have any leading theories on where I could have gone wrong in making/exporting the MIDI?
Notes are created in the game based on the MIDI file you use. I'm pressing notes to create the MIDI in LMMS/FL because thats what I've found intuitive when creating a beatmap.
If anyone can help me out it would be greatly appreciated! I have an existing rhythm game project I'm working on and I'm ready to add in a note spawner. I was recommended this tutorial and honestly it works great!! However there are many elements of it that seem way more complicated than I'm ready for and go into topics I simply don't need. I already have my songs, notes, buttons, logic for all of them, scoring, the absolute only thing I want to carry over to my project is the Note Spawning from MIDI mechanic... I can just manually place them in position but I feel that's a poor way to do it, and I'm sure there are array spawning methods, however I'm not experienced enough with coding to know how to do that without introducing possible lag or timing offsets... Would love any advice!!
The only thing that you'll need for your project most likely is all functions that work with midi in SongManager.cs and in Lane.cs, intheory you should be able to put those in your project and then use the array of timestamps and the array of the midi note types to spawn notes from, if you have any more questions feel free to join my discord and I'd love to help you out 👍
hello sir, thanks to you, i am learning how can i make the rhythm game well, i am so thankful that, btw i can not know what is melanchall drywetmidi it is, and where can i find it, and how can i put in my project of unity, and i am re-thankful that yout efforts, thank you sir
For it to work on android devices you likely want to use Input.GetTouch(0) and then use the position to determine what lane the screen touch corresponds to.
@@SkyanSam No, I have encountered the same issue, for some reason it seems not to be reading the Midi files because it works for the editor just fine too. That is the game doesn't start at all and no sound is being played after the build.
I've been following along to try and figure out how to make a Rhythm game myself, and it's been very helpful! However I'm confused about something that's happening with my notes, namely that they're not moving smoothly with lerp. Maybe I made a mistake with the code but the value of t in the notes jumps up by .5 every second and as a result the notes are just moving slowly. Do you know what this could possibly be? Thanks in advance! EDIT: I realised the mistake I made! Turns out I forgot to cast the result of GetAudioSourceTime as double, so it was probably being returned incorrectly
I'm trying to make a unity vr guitar hero like game, using the maps from frets on fire, i don't know why but adapting your code the tempo of the song and the tempo of the midi don't match
Ah, if you are using a custom map it may use a different tempo that might not map up with the seconds of the song. I'm guessing if you load the custom midi from the frets on fire map into LMMS, the midi song time will be different than what the song time should be. Maybe you don't want to get the tempo from time, but you want to get the tempo from time signature. I think there is a function in the DryWetMidi documentation that allows you to do that
HELP! I don't know if I'm doing something wrong but whenever I place the Song Manager script, I don't have the options to Have Audio Source, I just get a Greyed out "Script SongManager" and nothing after that Idk why :( (I'm completely new to this so it would help alot if someone could help!
Are your variables public? If not your audiosource should be defined like so "public AudioSource audioSource;" If they are public then something else seems to be causing the issue, restarting Unity may also help
Great tutorial, it's been super helpful! I've created my own guitar hero like game with it. I've added a feature so that users can adjust the the BPM of the midi file playback. However, I'm running into an issue where at lower BPMs, the screen will wipe all of the notes off the screen before ending the song. It's totally fine at say 120 BPM but not at 85 BPM for example. I'm pretty stumped on why this behavior is occurring and haven't been able to figure out what's causing it through debugging since it's not throwing any errors. Here's the code I used to change the tempo map based on user selected BPM (speed). Any help would be greatly appreciated! midiFile.ReplaceTempoMap(TempoMap.Create(Tempo.FromBeatsPerMinute(speed)));
I probably could reupload but too much effort and its only a minor error xD Someone commented on that too earlier I'll keep that in mind if i do something similar like this again