Scene changing in godot.

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

Hi , I have a problem in loading scenes in a project. I used the command “get_tree().change_scene” to switch from one scene to another.When i change from scene(1) to scene(2) , scene(2) opens.Now when i try to open scene(1) it dosen’t open and it dosen’t shows any errors.
Can you help me out with this problem ?

can you share the code/project?

p7f | 2019-02-07 16:59

When you are using .change_scene(), are you passing in a referenced to a PackedScene, or the path to the scene? If you’re passing in the PackedScene, is it possible that the scene has been freed already? Without seeing the code, it is pretty difficult to say one way or the other. Could you post a code snippet?

Eric Ellingson | 2019-02-07 21:42

I use path to the scene
enter image description here
In this project when the player hits the wall the scene ends and opens the menu scene.But when i try to open the level again it dosen’t open.
Can u help me pls ?

THE HELIX | 2019-02-08 05:10

Can you try this:

if "Player" in

Instead of this:

if == "Player":

I cannot say if this would work without having the full project, but i suspect you may be instancing your player twice, one on each level, and may be they are inside tree simultaneously a instant before the old gets freed (if you are freeing it). So the name of the new Player won’t be “Player”, as names are unique.

p7f | 2019-02-08 10:54

Also, i think you should handle this on process… physics process is for physics related operations.

p7f | 2019-02-08 10:55

I didn’t undestand how i can instance or free a node.
can u give some reference to it.

THE HELIX | 2019-02-08 13:01

I really need to see your project for that, cause i don’t know what have you done.

p7f | 2019-02-08 13:08