In my 2D game player has the ability to destroy crates, objects with two collision shapes. When destroyed, crate spawn items that also have collision shapes. But when the following function called many similar errors are displayed in the Godot console
Code:
func _on_Crate_item_dropped(collectible, pos):
collectible.init(pos, Vector2(rand_range(30, 100), rand_range(-10, 10)))
$CollectibleContainer.add_child(collectible) # error occurs here
Error:
ERROR: Can't change this state while flushing queries. Use call_deferred() or set_deferred() to change monitoring state instead.