+1 vote

Hello. i have been trying to set up a level loading system that does not switch scenes.
in each level there is light2D's and a canvas modulate along other things.

when i instantiate a level and add it to main as a child it loads, but for some reason the CanvasModulate is not doing anything.

here is my loader code:

func load_level(file : String):
var new_level = load(file)
var level = new_level.instance()
level.name = "level"
if $"/root/Main/".has_node("level"):
    var old_level = $"/root/Main/level"
    for child in old_level.get_children():


this code runs in a singleton.

any idea how to fix the issue/ how to implement non whole scenetree levels?

in Engine by (53 points)

For future reference if someone gets this obscure bug:
managed to work by using remove node on the old level and queue_freeing it afterwards instead of replace by.

2 Answers

+2 votes

I just wanted to thank you for sharing this. I have been having a near identical issue. Your solution did not immediately work for me. To fix things I also had to add a one game-loop delay between the old scene being removed and the new scene being created. I assume something about two CanvasModulate2d nodes operating on the same layer causes problems? I was able to solve my version of the issue by deferring the creation of the new scene, whether by using call_deferred() or the briefest of timers.

Again, just adding to this in case someone else comes along. Thanks for sharing your solution and starting me in the right direction!

by (18 points)

I am glad my debugging efforts were useful :)

+1 vote

seems like a known bug https://github.com/godotengine/godot/issues/39182 and yes, calling remove_child(old_scene) before old_scene.queue_free() a workaround for now.

by (82 points)

i think you meant




that's what works for me

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.