0 votes

I addedchild the room through the map and then addedchild the door to the orientation. If you go through the door to another room, the room becomes calldeferred("removechild") .

But in this case 'canprocess: Condition "!isinside_tree()" is true. Returned: false' is displayed. Other than this, it easily moves from room to room without any problems.

I'm not sure if this problem arises by calling remove_child like a door instanced in a room.

The tree order always changes the position after addchild statement in the room's _ready() function just once. After that -> the statement is treeentered() and _ready() is called.

Sorry for not being able to show you the code. Thank you in spite of my poor English skills.

+) Is there a problem with a function that is called separately when creating an instance? This function is called for the purpose of saving variables only.

Godot version 3.3.2
in Engine by (75 points)

1 Answer

0 votes
Best answer

Hi,
your description is somewhat hard to read (no offence).

This error often occurs when you attach a node to the tree via addchild and immediately call a function that expects the node to be in the tree. Because addchild takes a tiny while to actually put the node in the tree.
What you want is to ensure this has properly happend. Wait until the signal "tree_entered" or even better "ready" has been emited before doing anything with the newly attached node.

by (3,932 points)
selected by

Thank you.

But I tried that and I still get the error !isinsidetree() .

I'll post a link to my code here. I'm not familiar with github, so please forgive me for uploading it as a drive.

https://drive.google.com/drive/folders/1K1pZHwVIUod3tm1qbgLQ2S-K8rgR3pBI?usp=sharing

Hi,
please provide the whole error message with the line number and script name of the occurance.

https://drive.google.com/file/d/1TLteEnfn6pUtLLWICPZiWSz8PNZwVTsW/view?usp=sharing

Sorry, the lines aren't even numbered, and the errors are so vague it drives me nuts.

However, although an error message appears, there is no other problem. I just hate to see that red color. Of course, if the project becomes huge, it may come out mixed with other problems.

After browsing through your code i guess the "problem" is caused by the removechild. All nodes to process get collected, then all process calls are executed. If the removechild gets executed before the removed child process call the nodes process call will fail in this cycle.
You would have to disable processing on the child one cycle before removing ... or ignore the error, it would cause no harm anyway.

my two cents:
... i would prefer to not add and remove childs if not absolutly necessary. Fiddling around with the scene tree isnt ideal. Turn off processing, physics and visibility should do it too.

Then, after removing all the doors and players in Room.gd exiting_tree() , can I finally remove myself?

Thanks for the advice. I wanted a game like the Binding of Isaac, so I implemented it this way.

IMHO:
I dont see any necessity to add/remove all this objects. The player can reside on a layer above the scenery without any need to remove and attach it all the way. The doors can be parented to the rooms and when leaving only the room has to be "turned off". This would be way more simpler and the "timing" problems would not occure.

But there are many ways to archive this ... there is no right or wrong here

Thanks for the helpful comments. Really.

I think the door is supposed to open when all the enemies die anyway.

Enemies will also follow you with a map arrangement in the room. (AStar2D)

So, after hearing your valuable opinions, I thought it would be very good to widen the position of the room or to process the visible and physics_process(false) when leaving the room. It seems to prevent memory leaks that can occur when creating and removing each time.

Thank you very much. (My English was lacking.)

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.
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 webmaster@godotengine.org with your username.