+1 vote

I have a TileMap in my Scene which I store in a variable and then remove from the scene tree with "remove_child".
I then create a Thread to fill the tilemap with a large number of cells to create my world.
When the thread finishes, I add the TileMap back into the scene with "add_child", but this causes the game to freeze for several seconds.

Is there any way to avoid this lag but still be able to use a Thread to fill the TileMap? Since you can't access the scene tree from a Thread I don't see how...

Godot version 3.2.3
in Engine by (16 points)

Can you try calling the add_child method inside a call_deferred method?

It already was inside of a call_deferred method, called by the thread at the end when it is done adding tiles

Please log in or register to answer this question.

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.