how has_node or something that check if there is specific node work ?

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

i have this code
func _on_clsedoor_button_down():
if $MainHall/Teddyspawnpoint.has_node(“MainHall/Teddyspawnpoint/TheTeddyright”):
but somehow when i press button it doesn´t make queue_free

Not to nitpick, but as the problem is likely a coding issue, we need to be able to read the code. Could you edit your question, and format the code? You should be able to highlight the code in the webpage, and click the big curly braces tool. When you see the preview it should look like code.

An amazing number of problems are simply queue_free() versus queuefree() or the like.

CharlesMerriam | 2021-02-01 07:44

hi at least thx for reply i checked queue_free in my code here is again

func _on_clsedoor_button_down():

if $MainHall/Teddyspawnpoint.has_node("MainHall/Teddyspawnpoint/TheTeddyright"):

this is my code i made some tests but if there isn´t
“MainHall/Teddyspawnpoint/TheTeddyright” and i press down button it returns error node not found so i decided to look after somethink that will check if there is that node if yes then it will do queue_free() and if not it will do nothing
that´s why im here

ouhellouder | 2021-02-01 12:29

:bust_in_silhouette: Reply From: Lopy

You could use get_node(“MainHall/Teddyspawnpoint/TheTeddyright”) instead of your $.
get_node() is very similar to $, but one of the differences is that it will return null if it fails to find the Node, without any error message.
That would give you:

var node_or_null = get_node("MainHall/Teddyspawnpoint/TheTeddyright")
if node_or_null != null:

thanks man it worked

ouhellouder | 2021-02-08 08:56