How to Create a Zelda-like Top-Down Room

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

Hello, I’m making a top-down 2D like Zelda (recently binding of isaac).

However, there was one problem. After creating a room in each scene, random room generation in the level scene, add_child to the new room and remove_child the current room (using call_deferred) via the area signal when the player exits the door.

However, if the object and enemy are loaded at the same time, an is_inside_tree error occurs.

After that, when the game starts, I add_child to all the rooms at once and then run it, but it is also loaded all at once, so the speed is very slow and my laptop is cut off slightly even in the game.

After that I thought about multi-threading. I’m not sure if this multithreading will solve my problem, can I get some advice?

Thanks, and I’m really sorry for my short English

:bust_in_silhouette: Reply From: Wakatta

MultiThreading will only further complicate your problem.
But you are correct that it will help with that freezing you get from using add_child but that really depends on how your game is structured and you may not need it at all.

For example if your player is being removed and added to other scenes it may be best to always keep it in the sceneTree and position it as needed

Additional info

Have A look at episode 8

Forgive me for being late.

Yes. In your opinion, by placing the player in the same location as the Room scene, the player stays still, but by add child / remove child only to the Room, frame drops are reduced and more comfortable than when the entire room is instanced.

Thank you!

HorseGorilla | 2021-09-25 03:11