how to remove just one node

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

Godot 3.3.3 or Godot 3.5.1 ( i am trying not to use Godot 4.0 right now)

My Scene is


in test_level GD script i a section
func _on_Level1_body_entered(body: Node) → void:
if Global.S == 0:
Global.S = Global.S + 1

it loads Level-1A when that is done Level-1A goes back to Test_level…
once i get back to test_level i need to remove (or delete or get rid of) Level-1 node from the test_level scene

please note i need a code that i can copy and paste (with a short statement telling me how it works.) (notices BOTH of them)

Could you try and put the code in the code block next time? I don’t have a clue how to fix this tho. Maybe try looping through all nodes starting with “Level-1” and .queuefree()ing them? I couldn’t provide the EXACT code without more context, which is what you want. Maybe you should try Visual Scripting? It might be a bit easier for you.

DevBadger10 | 2023-03-27 23:58

wish i could help but DO NOT USE 4.0.1. I used 3.5.1 for a bit and came back to some pretty big changes

IC_Central | 2023-03-28 00:14

glad to see you agree with me @IC_Central

DevBadger10 | 2023-03-28 00:35

I have sloved it and made alot of inprovements

my scene looks like this

Test_level (
Level-1 [a scene by its self. Area2d/Sprite/CollisionShape2D]

[A] first i create an singleton

[B] inside my singleton (which i named

1 extends Node

2 var max_lives = 3
3 var lives = max_lives
4 var hud
5 var character = “SpongBob”
6 var item = “Coins”
7 var coins = 0
8 var strawberries = 0
9 var S = 0
10 var single_or_all = “all”
11 var qb := true
12 var qb1 := true
13 var qb2 := true
14 var level1 :=false

[line 14 is the one i need for this question]

i have 2 functions

func _ready():
if Global.level1 == true:


func _on_Level1_body_entered(body: Node) -> void:
if Global.S == 0:
	Global.S = Global.S + 1
	Global.level1 = true

when i run (or play ) the scene when i walk into the level-1 Area2D it
sets Global.level1 to true and loads Level-1A
at the end of of Level-1A it loads Test_level scene when it does the func _ready():
is ran and since Global.level1 is now true it removes the level-1 node

i hope this helps others.

Richard_A_Odell | 2023-03-28 06:10