Skip to content

Commit

Permalink
fix: default emotes
Browse files Browse the repository at this point in the history
  • Loading branch information
cazala committed Jan 10, 2025
1 parent 3363e8b commit c4804b4
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/lib/babylon/emote.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,17 @@ export async function playEmote(
const keys = targetedAnimation.animation.getKeys()
animation.setKeys([...keys])

const isAvatarAnimation = animationGroup.name.toLowerCase().includes('avatar')
// Determine if this is an avatar animation based on three criteria:
// 1. Single animation case: If the emote only has one animation group, it must be meant for the avatar
// (props always come as additional animation groups)
// 2. Group name: If the animation group's name contains "avatar", it's explicitly marked for the avatar
// (e.g., "Horse_Avatar" for the riding animation)
// 3. Target name: If the animated node starts with "Avatar_", it's part of the avatar skeleton
// (e.g., "Avatar_Head", "Avatar_Spine", etc.)
const isAvatarAnimation =
container.animationGroups.length === 1 ||
animationGroup.name.toLowerCase().includes('avatar') ||
target.name.startsWith('Avatar_')

if (isAvatarAnimation) {
// Strip any .# suffix from target name for matching
Expand All @@ -145,6 +155,8 @@ export async function playEmote(
nodeAnimation.setKeys([...keys])
emoteAnimationGroup.addTargetedAnimation(nodeAnimation, node)
}
} else {
console.warn('No matching bone found for', target.name)
}
} else {
emoteAnimationGroup.addTargetedAnimation(animation, target)
Expand Down

0 comments on commit c4804b4

Please sign in to comment.