Debug: add [Anim] diagnostic prints to animation pipeline
Adds targeted print statements at 3 key checkpoints in the GLB animation system to identify why animations don't play: 1. model_url presence (per unit, on every state rebuild) 2. AnimationPlayer presence + full track list (after model load) 3. Track resolution result in _play_unit_anim Generated with [Claude Code](https://claude.ai/code) via [Happy](https://happy.engineering) Co-Authored-By: Claude <noreply@anthropic.com> Co-Authored-By: Happy <yesreply@happy.engineering>
This commit is contained in:
@@ -621,9 +621,11 @@ func _add_unit_mesh(unit: Dictionary, team_color: Color, is_enemy: bool = false)
|
||||
if not def_id.is_empty():
|
||||
_unit_def_ids[iid] = def_id
|
||||
if def_id.is_empty():
|
||||
print("[Anim] iid=%s no cardDefinitionId — skipping model" % iid)
|
||||
return
|
||||
var def := ContentCache.get_definition(def_id)
|
||||
var model_url := _find_model3d_url(def)
|
||||
print("[Anim] iid=%s def_id=%s model_url=%s" % [iid, def_id.substr(0,8), model_url.substr(0, 60) if not model_url.is_empty() else "(none)"])
|
||||
if model_url.is_empty():
|
||||
return
|
||||
|
||||
@@ -662,7 +664,10 @@ func _add_unit_mesh(unit: Dictionary, team_color: Color, is_enemy: bool = false)
|
||||
var ap := _find_animation_player(model_node)
|
||||
_anim_players[iid] = ap
|
||||
if ap != null:
|
||||
print("[Anim] iid=%s AnimationPlayer found. tracks=%s" % [iid, str(ap.get_animation_list())])
|
||||
_play_unit_anim(iid, "idle", true)
|
||||
else:
|
||||
print("[Anim] iid=%s NO AnimationPlayer found in model tree" % iid)
|
||||
)
|
||||
|
||||
|
||||
@@ -709,6 +714,7 @@ func _resolve_anim_track(ap: AnimationPlayer, action_lower: String) -> String:
|
||||
func _play_unit_anim(iid: String, action: String, loop: bool = false) -> void:
|
||||
var ap : AnimationPlayer = _anim_players.get(iid, null)
|
||||
if ap == null or not is_instance_valid(ap):
|
||||
print("[Anim] _play_unit_anim('%s','%s') — no valid AnimationPlayer" % [iid, action])
|
||||
return
|
||||
# Resolve via CardAnimationBinding override first.
|
||||
var def_id : String = _unit_def_ids.get(iid, "")
|
||||
@@ -718,10 +724,12 @@ func _play_unit_anim(iid: String, action: String, loop: bool = false) -> void:
|
||||
if not override.is_empty():
|
||||
desired = override
|
||||
var track := _resolve_anim_track(ap, desired.to_lower())
|
||||
print("[Anim] _play_unit_anim('%s','%s') desired='%s' → track='%s'" % [iid, action, desired, track])
|
||||
if track.is_empty():
|
||||
return
|
||||
var anim := ap.get_animation(track)
|
||||
if anim == null:
|
||||
print("[Anim] get_animation('%s') returned null!" % track)
|
||||
return
|
||||
anim.loop_mode = Animation.LOOP_LINEAR if loop else Animation.LOOP_NONE
|
||||
if not loop and ap.current_animation == track and ap.is_playing():
|
||||
@@ -2017,4 +2025,3 @@ func _on_state_updated(state: Dictionary) -> void:
|
||||
|
||||
func _on_draw_pressed() -> void: Game.send_draw()
|
||||
func _on_end_turn_pressed() -> void: _set_mode(Mode.NONE); Game.send_end_turn()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user