0 votes

Hi,
At first maybe some explanations :)
I have two levels loaded parallel at once. they both are loaded in my main scene under InGame:

Game <--- script (Mainnode)
InGame (here I load my levels inside)
Level1
Level2

Inside Level2 is a trigger that sets a global variable (Globals.deletelevel).
This variable defines the Level i want to remove. In my case now its Globals.delete
level = 1.

Now in the gamescript i want to remove the Level defined by the the variable and this is what I'm struggling with right now...

from my knowledge I would do it like this:

$InGame.getnode("Level", Globals.deletelevel).queue_free()

but I get the following error:

Too many arguments for "get_node()" call. Expected at most 1.

I see the problem with the two arguments inside get_node() but i cant find a solution..
I hope someone can help me :)
thank you for your answers

asked May 24 in Engine by Philter (15 points)

1 Answer

+1 vote
Best answer

You need just one argument in get_node(): the string name of the node you're getting.

You're trying to make the string "Level1" out of "Level" and the value of Globals.delete_level. This is what + is for:

get_node("Level"+str(Globals.delete_level))
answered May 24 by kidscancode (17,132 points)
selected May 24 by Philter
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 How to use this Q&A? before posting your first questions.