Game randomly started lagging

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Afely

The project I talk about in this post

So I’m making a game, I decide take a break and close the editor. I come back a few hours later, open my project and playtest it before making any changes, and somehow it’s become completely unplayable. It slowly gets more and more laggy when you try and play it. I’ve looked over everything I was working on before closing the engine, I exported it, I sent it to a friend, turned off vsync, restarted my pc, nothing has any effect on it. Here’s some things I found that might have something to do with the cause:

  • There were a few lines of code that I’d written not long before exiting the engine that hadn’t saved. I rewrote them, checked other things I’d done around the same time, nothing.
  • When my friend tested it, they got an error that I wasn’t getting. I’m not sure what it means:


They also told me that it got stuck on the loading screen for them, which I also haven’t experienced.

I am completely lost as to what could be causing this. Nothing I do seems to change anything. It would also be ideal to get a quick solution, because I’m making this game for a game jam. No pressure :slight_smile:

Are you creating/writing files? If so, are you using the user:// prefix? Looks like your friend maybe installed the game in a write protected folder.

Are you using source control? If so, check out the latests diffs in the .project file and the .tscn files. I’ve had issues where somehow garbage values were stored there that weren’t visible from the editor, and it was messing up my collision masks.

Bernard Cloutier | 2020-10-29 17:46

I’ve just noticed you included a link to your project. Unfortunately, I’m guessing you set it up as private since I get a 404.

Bernard Cloutier | 2020-10-29 17:47

No, nowhere in my code have I created or written files. I don’t exactly know what source control is, so I’m probably not using it. And sorry, I’ll set it to public

Afely | 2020-10-30 03:04

I assumed you knew what source control was since you’re using github, also it l9oks like you just used it to dump your project in one big go. Usually, you keep a version of your project on github and push your changes to it gradually, allowing you to easily keep track of versions and go back to previous versions. I strongly suggest you take a tutorial on git, as it will save you lots of trouble going forward.

I’ll try and download it later today. In the meantime, try the profiler to see where the delays are coming from:
Debugger panel — Godot Engine (stable) documentation in English

Bernard Cloutier | 2020-10-30 17:09

Just wanted to add to the importance of using git for your projects: if you had used it properly, you could have easily gone back to the version without the lag and compared the changes you made to find the source of the issue. Instead, you have to go “oh no, what did I change” as you scour each file.

Lesson learned, I hope! :slight_smile:

Bernard Cloutier | 2020-10-30 17:16

Yeah, definitely sounds like a good idea. I’m gonna do that for all my games in the future, because this is a total mess. You really don’t learn the importance of backing up your files until something like this happens, haha

Afely | 2020-10-30 19:23

Yup, don’t worry, I think every dev has got to learn that the hard way before they sit down and bother learning git. Even if they don’t want to admit it :stuck_out_tongue:

Bernard Cloutier | 2020-10-31 01:30

:bust_in_silhouette: Reply From: Bernard Cloutier

Lol do you think you’ve got enough cameras in your scene over 4000 cameras - Album on Imgur

In many of your scripts, you’re instantiating cameras in the _process function (i.e. every frame) and just adding them to the tree. In this case, the bullet.gd script is the culprit.

I suspected something like that (maybe because I once made a similar mistake, who knows :wink: ), so I paused the game and opened the “remote” tab of the scene tree. That shows you the current tree of the game you’re debugging.