+1 vote

I'm working on trying to get online multiplayer set up for a game of mine, and as part of that wanted to export the game file so I could more easily have multiple copies of it open at once (and test across different computers).

However, my game is crashing when exported as an executable!

Here's a shot of the debugger when I run in editor to show there aren't any game breaking issues.
Debug Image

Now when I compile the files I get:

enter image description here

The game seems to be failing to find some scenes and script files. However, I can open up the .pck file and find those scenes inside of it! Adding them explicitly to the resources tab in the editor's export settings doesn't seem to change anything.

enter image description here

This is happening for about 3-4 scene files, basically everything that's loaded at game start- including my main scene.

Here's the editor's export menu:
enter image description here
enter image description here

I added the "." to make sure I was importing ALL files since others have had issues with exporting and dynamic loading- but I don't think that's the issue due to the presence of these files/scenes in the .pck

I'm using the Creature 2D Runtimes so I don't have a lot of flexibility when it comes to changing versions. None of the broken scenes reference the CreatureGodot class that it packages, and I've also tested against custom runtimes so I can confirm that's not really the issue.

Has anyone seen something like this before? I've encountered a similar issue in this question but it's been inactive for about a year.

Godot version 3.2.2 stable
in Engine by (35 points)

Double-check that all paths in scripts use the correct casing, as the virtual PCK filesystem is case-sensitive unlike Windows': https://docs.godotengine.org/en/latest/tutorials/best_practices/project_organization.html#case-sensitivity

I checked for that- you can see in the example above that "res://UI/Deck/Card.tscn" is in the same case in the .pck despite not being found by the game.

However I think I've found a clue- although I'm not sure how to resolve it. I believe the error is the "Cannot load byte code from file 'res://UI/Deck/Card.gdc'

enter image description here

The card fails to load, then I believe the "Dealer" object which deals card is failing to load as a result. The Dealer object exists on the board, so the Board scene is then crashing next.

The Board is preloaded by the Game Manager autoload, so of course the whole game is then crashing on startup.The "Game Runner" default scene crashes because it references this board, which doesn't exist.

enter image description here

Here's the script file from our first error. It's throwing a parse error because it can't find the _ready() function.

enter image description here

This happens here. There's a "self._ready()" call if the object is unitialized before I pass in the different Card parameters, because I've found that when I create the card scene and tell it to initialize it can sometimes initialize before it's ready. When that happens, the onready variables aren't loaded and are treated as nulls, causing a crash.

This isn't a trick that I just do here- I do it in multiple places. Clearly, however, it's some kind of bad practice and is causing a crashed script- which is in turn crashing entire chains of scenes.

Does anyone have any advice as to how I should handle this case instead? Why wouldn't my card scene have a ._ready() function, when it extends Control? And why would this work in the editor, but not in the actual debug version of the game?

Adding the scenes to the scenetree before initializing them and removing the call has fixed the issue.

That's obviously the correct way to do things, so this is definitely on me. It seems that we can't call _ready() explicitly in the actual executable but can in the editor. I'm not sure why this is exactly, or if it's been fixed in a later version of Godot.

This shouldn't be an issue for 99% of games since calling _ready() explicitly is a bad practice to begin with.

I'm not sure if this is true of newer versions of Godot, but if this is intended behavior there should be a warning inside the editor to prevent issues like this from happening to others.

Thanks to everyone who took the time to take a look and think about it!

1 Answer

+1 vote
Best answer

I'm new to this question board style interface, so I goofed up and included the question as a comment. Here it is again in case anyone googles their way onto this thread:


Adding the scenes to the scenetree before initializing them and removing the call has fixed the issue.

That's obviously the correct way to do things, so this is definitely on me. It seems that we can't call _ready() explicitly in the actual executable but can in the editor. I'm not sure why this is exactly, or if it's been fixed in a later version of Godot.

This shouldn't be an issue for 99% of games since calling _ready() explicitly is a bad practice to begin with.

I'm not sure if this is true of newer versions of Godot, but if this is intended behavior there should be a warning inside the editor to prevent issues like this from happening to others.

Thanks to everyone who took the time to take a look and think about it!

by (35 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.