From 727598c2bc782ce2674e1c7bc59c873271f4c228 Mon Sep 17 00:00:00 2001 From: Tanish Manku Date: Thu, 19 Dec 2024 22:25:03 -0800 Subject: [PATCH] Character Engine: Smoothen out the interpolation by clamping instead of pausing --- .../Editor/Engines/CharacterAnimationEngine.ts | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/app/pages/PageEnigma/Editor/Engines/CharacterAnimationEngine.ts b/app/pages/PageEnigma/Editor/Engines/CharacterAnimationEngine.ts index 3e6cf46788..8f28aeb585 100644 --- a/app/pages/PageEnigma/Editor/Engines/CharacterAnimationEngine.ts +++ b/app/pages/PageEnigma/Editor/Engines/CharacterAnimationEngine.ts @@ -105,14 +105,18 @@ export class CharacterAnimationEngine { nextAction.setEffectiveWeight(progress); // Make sure we hold that last frame for the previous action - prevAction.paused = true; + prevAction.clampWhenFinished = true; // The next action should stay at the first frame nextAction.paused = true; + // Necessary to ensure the actions are active - the default is inactive, mixer won't do anything prevAction.play(); nextAction.play(); - mixer.setTime(timestamp / 1000); + + // The clip time would still be relative to the previous clip + const clipTime = timestamp - prevClip.offset; + mixer.setTime(clipTime / 1000); console.log("Prev action status") console.log(prevAction); } @@ -146,9 +150,14 @@ export class CharacterAnimationEngine { // Play only this action const animationAction = mixer.clipAction(animationTrack); + + // Since it's the only clip in this timestamp, make it full weight and make sure it's not paused (from interpolation or otherwise) animationAction.setEffectiveWeight(1); animationAction.paused = false; + + // Necessary to ensure the actions are active - the default is inactive, mixer won't do anything animationAction.play(); + mixer.setTime(clipTime / 1000); console.log("Action status") console.log(animationAction);