Quick answer: Set the method track’s Call Mode to Immediate for ordered, in-frame calls. Deferred batches to end-of-frame and can reorder relative to other logic.
An attack animation has method-track calls: enable_hitbox, then play_sound. With Deferred mode, the sound sometimes plays before the hitbox enables, breaking combo timing.
Call Mode
Each AnimationPlayer method track has a Call Mode:
- Immediate: calls execute during the animation step, in keyframe order.
- Deferred: calls queue to end of frame, executed via call_deferred.
For ordered gameplay logic, use Immediate.
When Deferred Is Right
Deferred is safer when the called method modifies the scene tree (add/remove nodes). Immediate calls into tree-mutating methods mid-animation-step can cause issues.
For pure logic (enable flags, play sounds), Immediate is fine and deterministic.
Split Concerns
If you need both ordered logic AND tree mutation:
- Immediate track for gameplay flags (hitbox on/off).
- Separate Deferred track for spawning effects.
Verifying
Play attack animation. Hitbox enables before sound, every time. Combo timing consistent across frames.
“Immediate = ordered, in-frame. Deferred = batched, end-of-frame. Pick by whether order matters.”
For frame-perfect fighting games, Immediate is mandatory — deferred introduces a 1-frame variance that competitive players will feel.