![]() |
Attention | Topic was automatically imported from the old Question2Answer platform. |
![]() |
Asked By | redstonecreeper8 |
I’m having some strange issues with removing a child node when changing scenes and I’ll try to explain what’s happening because I really have no clue what is going on.
I have a planet and a rocketship that can fly around. Whenever you touch down on the planet, it calls a change scene function on a singleton script:
func change_scene(scene):
player.get_parent().remove_child(player)
get_tree().change_scene(scene)
The player has to be removed so that I can add him back in to the new scene. This works great if, and only if, you land on the bottom of the planet. Land near the north pole, and I get a crash and error message “Attempt to call function ‘remove_child’ in base ‘null_instance’ on a null instance.” There should be no null instances involved, I have the console print out both player and player.get_parent() and they are both nodes. I can provide a project file if it helps because this is really peculiar.
Have you tried stepping through the code with breakpoints in that particular case?
Not that proficient at debugging myself but a quick YouTube search got me this, best of luck!
Lazarwolfe | 2021-02-09 16:37