3 godot 4 errors that don't show up until you run the game

ran into these a bunch lately so figured i’d share in case it saves someone some time.

  1. spawning stuff inside body_entered gives “Can’t change this state while flushing queries”. use add_child.call_deferred(coin) instead, and set_deferred("monitoring", false) if you’re turning an area off.

  2. with .bind(), your bound values go after the signal’s own args. so item_selected.connect(_on_item_selected.bind("weapon")) needs func _on_item_selected(index: int, slot: String). flip them and it errors and never runs.

  3. long paths like $HUD/MarginContainer/HealthBar break the second you move nodes around. right click the node, pick Access as Unique Name, then use %HealthBar. also if a signal is already connected in the editor, don’t connect it again in code or it fires twice.

i kept hitting these with AI tools too, so i made a free set of rules for them if anyone wants it: GitHub - scoyoc5/godot-ai-agent-rules: Free Cursor rules + AGENTS.md that stop AI (Cursor, Claude Code, ChatGPT) from writing Godot 3 code in Godot 4 projects: yield, export, onready, old connect(), invented APIs. MIT. · GitHub