0 votes

update
That was my fault, I was not clearing the correct node.
free() and queue_free() works fine and as described.

I am removing a node using

self.queue_free()

the node is being removed from the screen, all is ok, but when I am checking from the parent

self.get_children()

the node is returned!
also

self.get_child_count()

does not reset to zero!

Is this way correct to remove the node?

in Engine by (25 points)
edited by

do you check in the same frame where you queue_free?

I keep checking in the _process(), but it is not geting reseted.

1 Answer

0 votes

queue_free doesn't immediately remove the node from the tree, it does that at the end of the frame, due to many unexpected side-effects using free could cause (unless you really know what you are doing).

You can try to remove the node from the tree though, if you just want it to not be there.

by (28,966 points)

The issue continue as long as the game is running, I waited minutes fot it!
I am removing a level and adding a new one, is there a better wat?
Every level is a scene thet I inctance and add to the root node by code.

If the node is still there minutes after you did queue_free (or removed from tree), it's very likely you made a mistake. Do you see any error in the console? What is your code?

No errors, I have tried free() alao with the same results. The scene is getting removed from the game visualy but in the code it is not.

Can I see your code?

I will post it later today,,

# this is the child node
func _process(delta):
    if(get_overlapping_areas().size() > 0):
        var overlap = get_overlapping_areas()[0]
        if(overlap.is_in_group("drag") and overlap.get_parent() == self.get_parent()):
            overlap.set_pos(self.get_pos())
            self.get_parent().emit_signal("dropped")



# this is the parent node
signal dropped
func _ready():
    self.connect("dropped", self, "on_dropped")

func on_dropped():
    self.queue_free()

And the parent is still in the tree? Are you sure it was really called? How did you deduce it's still in the tree? Do you still see it in the remote debugger?

Does this happen too in a minimal project? I made one with the same structure as your code and it works.

(Note: not sure why you used a signal here though, why not just call get_parent().on_dropped() ?)

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.