godotengine / godotengine/godot-docs

call_group("mobs", "queue_free") does not work reliably without waiting a frame (Godot 4)

Open
#11,717 3 comments 1 reaction 0 assignees View on GitHub
area:getting started bug
Dominant language
reStructuredText
Stars
5.7k
Forks
3.8k
Avg merge
1d 20h
Merged PRs (30d)
25

Description

In the "Your first 2D game" tutorial, mobs are removed using:

get_tree().call_group("mobs", "queue_free")

In Godot 4, this can fail when called in the same frame as game reset (e.g. new_game()),
because both call_group and queue_free are deferred.
As a result, mobs remain in the scene, which is confusing for beginners.

Workarounds that work reliably:
- Waiting one frame:
await get_tree().process_frame
get_tree().call_group("mobs", "queue_free")

- Or directly freeing:
for m in get_tree().get_nodes_in_group("mobs"):
m.free()

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.