Skip to main content

Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines

I think it might even be less prone to lag issues, at least the way we did it.

  1. Get a list of all notes to be played (note + start time). We cheated a bit and just let our composer export a midi file for us :)
  2. For every note just instantiate a note-scene at position.y = start_time_in_seconds * pixels_per_second
  3. All notes are under one parent node
  4. Instead of "moving the parent note by some value" just absolutely reposition the parent note at position.y = current_playback_time_in_seconds * pixels_per_second * -1 every (physics) frame

This way, the notes move always in sync with the music, if the music skips/lags, the visuals will also skip/lag.
This approach might lead to performance issues with very large songs (lots of notes), but for us this worked. For note detection we don't use physics at all btw, we just check if the note is withing a given timeframe of their start time. i.e.:
var min_time = note.start_time - tolerance_time
var max_time = note.start_time + tolerance_time

if current_playback_time >= min_time  and current_playback_time <= max_time -> then note is hit

Very interesting, thank you!

When I did musical rhythm game last jam - I just made an array of notes with their length and pauses (also converted from midi) - and just went over the list and initiating a visual note que 1 second in advance of emoting a sound note. And when the visual notes had timers attached to them against which the input was checked - whether it's within the allowance interval. 

So it looks the same, but instead of music playback - checks against timer attached to visual ques.  Although I didn't do the classic "lines" and was using scaling-appearing notes :)

Not sure though whether timer works in physical, or something else - I didn't get that deep into engine yet. But for some reason I thought that asking timer is "faster" than asking a music file. Although when it's loaded - there is probably no difference?

(+1)

Not *much* difference at least when using the music file (it is also converted into an array of NoteData (custom class with some data like start_time, frequency etc)).
This array is checked every physics_frame (though the whole array is split into the 4 bins for the 4 lanes first, so there are maybe like 90-ish notes per bin per physics_process frame to check). For larger songs this could lead to problems but for this it worked fine :)

Interesting, thank you!