diff --git a/Client/origin-client/scenes/game/game_screen.gd b/Client/origin-client/scenes/game/game_screen.gd index d5003e5..40b95f2 100644 --- a/Client/origin-client/scenes/game/game_screen.gd +++ b/Client/origin-client/scenes/game/game_screen.gd @@ -693,18 +693,33 @@ func _find_animation_player(node: Node) -> AnimationPlayer: ## Case-insensitive track name resolver with fallback aliases. ## Returns the exact track name in the AnimationPlayer, or "" if not found. +## Handles multiple naming conventions exported from DCC tools: +## "Idle" — bare name +## "lib/Idle" — library-prefixed (GLTF named library) +## "Merlock.Attack" — dot-prefixed model name (e.g. Blender action sets) +## "Merlock_IDLE" — underscore-prefixed model name func _resolve_anim_track(ap: AnimationPlayer, action_lower: String) -> String: - # Strip library prefix (e.g. "model/Idle" → "idle") for comparison. - for full_name: String in ap.get_animation_list(): - var short := full_name.get_slice("/", full_name.get_slice_count("/") - 1) - if short.to_lower() == action_lower: - return full_name - # Try known aliases. + # Try: canonical action name first, then aliases. + var to_try : Array[String] = [action_lower] for alias: String in ANIM_ALIASES.get(action_lower, []): + if alias != action_lower: + to_try.append(alias) + + for candidate: String in to_try: for full_name: String in ap.get_animation_list(): - var short := full_name.get_slice("/", full_name.get_slice_count("/") - 1) - if short.to_lower() == alias: + # Strip library prefix (e.g. "lib/Idle" → "Idle"). + var s := full_name.get_slice("/", full_name.get_slice_count("/") - 1) + # 1. Direct match after library strip. + if s.to_lower() == candidate: return full_name + # 2. Dot-prefix stripped (e.g. "Merlock.Attack" → "Attack" → "attack"). + if "." in s: + if s.get_slice(".", s.get_slice_count(".") - 1).to_lower() == candidate: + return full_name + # 3. First-underscore-prefix stripped (e.g. "Merlock_IDLE" → "IDLE" → "idle"). + if "_" in s: + if s.substr(s.find("_") + 1).to_lower() == candidate: + return full_name return ""