Skip to content

Commit

Permalink
update Animator
Browse files Browse the repository at this point in the history
remove all mentions of "name" field in animator
always use clip
  • Loading branch information
nearnshaw committed Oct 19, 2023
1 parent 4ca9418 commit 86984f5
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions src/npc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,6 @@ function addNPCBones(npc: Entity, data: NPCData) {
Animator.create(npc, {
states: [
{
name: data && data.idleAnim ? data.idleAnim : 'Idle',
clip: data && data.idleAnim ? data.idleAnim : 'Idle',
loop: true
}
Expand All @@ -199,7 +198,7 @@ function addNPCBones(npc: Entity, data: NPCData) {
if (data && data.walkingAnim) {
npcDataComponent.get(npc).walkingAnim = data.walkingAnim
let animations = Animator.getMutable(npc)
animations.states.push({ name: data.walkingAnim, clip: data.walkingAnim, loop: true })
animations.states.push({ clip: data.walkingAnim, loop: true })
}

break
Expand Down Expand Up @@ -619,8 +618,8 @@ export function handleWalkAway(npc: Entity, other: Entity) {

export function playAnimation(npc: Entity, anim: string, noLoop?: boolean, duration?: number) {
let animations = Animator.getMutable(npc)
if (animations.states.filter((animation) => animation.name === anim).length == 0) {
animations.states.push({ name: anim, clip: anim, loop: noLoop ? false : true })
if (animations.states.filter((animation) => animation.clip === anim).length == 0) {
animations.states.push({ clip: anim, loop: noLoop ? false : true })
}

let npcData = npcDataComponent.get(npc)
Expand Down Expand Up @@ -656,8 +655,8 @@ export function changeIdleAnim(npc: Entity, animation: string, play?: boolean) {
npcData.idleAnim = animation

let animations = Animator.getMutable(npc)
if (animations.states.filter((anim) => anim.name === animation).length == 0) {
animations.states.push({ name: animation, clip: animation, loop: true })
if (animations.states.filter((anim) => anim.clip === animation).length == 0) {
animations.states.push({ clip: animation, loop: true })
}

if (play) {
Expand Down

0 comments on commit 86984f5

Please sign in to comment.