[SOLVED] Game runs smoothly on editor preview but lags when built / exported

Hello! First time on the forums, hope I’m doing this right. If there’s anything I should add to this please let me know ;o;

I’m currently working on a rhythm game: Notes move from the top of the screen towards the bottom, and you hit certain keys depending on the note’s placement/column/“lane” at the right moment. What I need is the notes spawning at the correct time, at the correct speed.

This actually works that way in my game! …Just in the previews you access from GDevelop’s editor, though. If I were to stream the preview in Discord, the game runs smoothly in every scene except the one where the gameplay happens (The title screen and character select screen specifically, they both run very well, just like in the editor’s preview). A friend suggested me exporting a build of the game instead, to see if the problem persisted. It did.

When streaming/on an exported build, the game (only in the gameplay scene):

  • Has somewhat laggy/slow animations (For context: There’s some looping animations on the sides of where the keys spawn. They’re short and not too big though)
  • Visual effects from the buttons/keys lag too
  • When notes spawn, they spawn much later than expected. They spawn in the same order and distance between them that they should though.
  • Sound is fine however, and runs like when previewing from the editor (AKA doesn’t lag at all)

Here’s a snippet from the chart section of my events, which is basically the same for every time a note is spawned (just changing the song’s offset that sets the moment the note(s) should spawn):

What the code does is:

1.- Spawn two notes on two different lanes at the same time (just in this case, hence why you see a “Note” object and also a “Note9” object, as it’s the note type that should spawn on the ninth lane/column)
2.- Set their Z-order so they’re visible
3.- Add a permanent force to both notes that moves them downwards based on the song’s BPM and “songspeed” (which is an additional variable I have there to tweak the notes’ speed)

I would put the builds (plural because I did this twice today, one with changes and one as it was before I noticed the lag) here in case anyone wants to test to see if they get this same problem with the game but the chart has a placeholder song that wouldn’t let me put them here as per the forums’ rules. I was thinking of maybe exporting it muted song-wise (AKA replacing the song with an audio file that’s just silence but the same length as the original song), but I don’t know if that could help noticing the desync of the notes (as it’s just silence).

Do note I tried fixing this adding a “* TimeDelta()” next to when SongSpeed is mentioned but it just made things messier (notes wouldn’t even spawn in the correct order with this).

If there’s anything else I should show or tell about the scene’s events/game please let me know. Any help would be very appreciated ;_; Thanks in advance

1 Like

ALRIGHT so I found the cause of the error, but I don’t really know what to do from there.

When two or more events spawn at least one note each, the game lags when streaming on Discord/playing on an exported build.

When it’s just one event, the game runs smoothly anywhere.

So the problem (I think?) is that somehow the events (even with the trigger once condition) lag the game.

But how else can I spawn the notes at the correct rhythm without this problem? ;_;

I also edited the code a bit: Instead of adding a permanent force once, it’s constantly adding instant forces. I don’t know if that might affect the game’s performance too, I haven’t seen a difference really.

I tried putting the first event as a parent and the following events as sub events from the event that comes before each of them but it didn’t work (the following notes after the first event straight up didn’t spawn).

I also tried optimizing the animations’ events too but it didn’t help either. (it didn’t make it worse, it just didn’t make a change on the performance)

Here’s the entire chart’s code so far (in case it helps):

1 Like

…Hello again ;v; sorry to post a lot in this topic, I’m starting to become a little anxious about not being able to find a solution.

I’ve changed a few things in the events that manage the gameplay, and I’ve got it to lag a bit less, but it still desyncs and well, lags. It makes the game unplayable because rhythm games must be as precise as they can with their notes/inputs/etc.

Thus, I decided to share the project files and the last build I made nonetheless. I really really really need help in this. Been trying to fix this since the last reply non-stop (I didn’t notice I’ve been 2 hours staring at the computer and after that my eyes started to kinda hurt x_x so if anyone responds I’ll probably take a bit to respond unless it’s like, hours after this reply) and nothing has worked so far.

I hope the song doesn’t cause any problems (the artist explicitly allows his songs to be used in rhythm game charts, so don’t worry). If that isn’t enough, let me know and I’ll delete the link ;;

This is my first time sharing a GDevelop project file somewhere, so let me know if I did anything wrong.

Project Files:
G-RHYTHM.zip

Exported Build:
G-RHYTHM_Build_Windows

Note: Some notes in the events may be in Spanish, as that’s my native/main language. They don’t explain much though. If that confuses you either way, let me know and I’ll change the notes to English asap. Sorry I didn’t do it before sharing these aa (I did change the groups’ names/descriptions to English however)

1 Like

Heyyy so I don’t know how but I fixed this. The streaming part not so much because it seems to be a problem caused by Discord Nitro but the game runs smoothly now.

I really wish I knew what I did exactly so I could share it here ;O;