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

Basically:
I have a menu with buttons that lead to different levels, and each button, except the first, is inactive until the player completes the level before it. I've made each node inactive by placing a node with a color rect and sprite on top of it.

The game cycle also goes like this:
Person selects level from menu
Person plays level
When level is complete, they are taken to a success screen
Person presses button to take them back to menu

What I want to do is just to delete the node, preferably from the script that checks if the level is complete (attached to the world node). From what I can tell, though, get_node() only works for nodes inside the same scene.

So calling

get_node("/root/LevelSelect/Control/NewYork/inactiveny").queue_free()

in the script attached to the world node inside Level1.tscn doesn't delete the node inactiveny inside SelectLevel.tscn. I've tried other variations of the path, but they don't work either.

I don't really have a stellar understanding of how this game engine works, but I feel like there might be a really simple fix that I'm missing. Also, each inactive is currently saved as an instance of a scene, if that complicates matters.

in Engine by (14 points)

1 Answer

0 votes

I think that You can't delete a node of a scene that is not loaded yet. The nodes of this scene only is loaded when the scene is loaded.

You can do this:
- Create a script that contais all of "status" that you can set up. Like a save game.
- Put this script in autoload. This script will works like a Global script.
- In the scene that you want make the changes, consult the info on global script and then show or hide the nodes.

by (171 points)

node.show() and node.hide() is definately the route to go and will save you many sleepless nights

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.