Fix: animation track resolver handles dot/underscore model-name prefix
GLB animations exported from DCC tools often prefix track names with
the model name using a dot (Merlock.Attack) or underscore (Merlock_IDLE).
The previous resolver only stripped the GLTF library prefix (before '/').
Now tries three forms after stripping the library prefix:
1. Direct match ("Idle" → "idle")
2. After last dot ("Merlock.Attack" → "attack")
3. After first underscore ("Merlock_IDLE" → "idle")
Each form is tried for the canonical action name and all its aliases,
so "Merlock.Attacked" maps to "damaged" via the "attacked" alias, and
"Merlock.Move" maps to "moving" via the "move" alias.
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:
@@ -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 ""
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user