The Godot Q&A is currently undergoing maintenance!

Your ability to ask and answer questions is temporarily disabled. You can browse existing threads in read-only mode.

We are working on bringing this community platform back to its full functionality, stay tuned for updates.

godotengine.org | Twitter

0 votes

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 'removechild' in base 'nullinstance' 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.

in Engine by (67 points)

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!

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 Frequently asked questions and 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 [email protected] with your username.