Game crashes after changing scenes

Godot Version

4.2

So, i’ve been working on a turn-based combat rpg since i’ve learned godot, but i’ve got stuck at something, basically, there’s two parts to the game, which are:

The overworld - A 2d Scene containing the player and some assets like the danger zone which is the node that sends the player to the battle
The battle - A 3d scene made out of basically sprites 3d.

Everything worked fine until i started to code the flee battle button, everything worked fine, the % rate of flee success, but, whenever i try to switch back to the 2d scene the game just crashes, here’s some of the code:

image
image
image
image

BattleSettings.original_scene is set by the danger zone node.

1 Like

Is it a crash or a stack trace? Do you get any error messages? res://scenes/over doesn’t have a .tscn file extension, is that the complete path?

It has a .tscn file extension, to make sure i wasn’t mispelling it i right clicked the scene and copied it to paste it on the node.

I don’t get any errors, the game just suddenly crashes.

1 Like

Okay seems like i found the issue, for some reason the WorldEnvironment from both scenes make the game crash. I try deleting WorldEnv from the 2d scene and everything worked fine.

1 Like

Have the same issue and almost EXACTLY the same setup - an overworld scene and a battle scene. When going from battle (starting scene) to Overworld, everything’s dandy. When trying to go back to battle scene, it just silently crashes, and it’s driving me crazy. I deleted my “World environments” from both scenes, but it didn’t help. I mean, really? Should I step over thousands of lines to catch the moment when it crashes? :frowning:

Yeah thats a bit strange, how’s your scene changing code?

Thank you. After some troubleshooting I solved it, although the reasons were totally different from your case. Looks like it was a bad idea to for a child node to add a child to its parent during _ready() call (at least two bad decisions in one string!). Since the parent wasn’t yet ready, I added the child using call_deferred(), which was causing the crash. Maybe adding a child from a child node’s “ready()” was causing the “ready” functions of all hierarchy to rerun and effectively create a memory leaking loop, but anyway’s that was an awful hack that I created to quickly plug some hole and left forgotten.

1 Like