Issue with switching scenes (collision object removal node thing)

Godot Version

4.5.1 stable

Question

I tried changing the current scene using get_tree().change_scene_to_packed(scene) in an area 2d node. The scene changes for a moment and then dissapears. The error "scene_switch.gd:14 @ _on_area_entered(): Removing a CollisionObject node during a physics callback is not allowed and will cause undesired behavior. Remove with call_deferred() instead." is displayed. How do i make this work ;-;

It tells you to use call_deferred(), so you should try if that works:

get_tree().change_scene_to_packed.call_deferred(scene)
1 Like

thanks! that worked c: