0 votes

I am making a dungeon crawler and when the player changes levels, a new scene is loaded and a new instance of the playr is created. All the player's information are stored on global script, when I try to go back to a previous level, I get this error:

Invalid type in function 'add_child' in base 'Node2D (Game.gd)'. The Object-derived class of argument 1 (previously freed instance) is not a subclass of the expected argument class.

Can someone explain?

asked Jun 30 in Engine by Guiguis_Galdis (24 points)

1 Answer

0 votes

Well, I'm not sure about exact reason for this error. If that scene was instanced without errors for the first time and freed later, I can't see why it can't be instanced again.
You can try another approach: do not delete previous scene, but hide() it, and show() when player returns

answered Jun 30 by 1shevelov (76 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.