From d696f53e63da7a57bb2925354730f67d0eae4be7 Mon Sep 17 00:00:00 2001 From: AstrlJelly Date: Fri, 27 Oct 2023 14:33:39 -0400 Subject: [PATCH] better anim function this is more efficient AND it'll produce more consistent results when starting an animation between tempo changes :D (it no longer iterates through a list twice) --- Assets/Scripts/Util/AnimationHelpers.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Assets/Scripts/Util/AnimationHelpers.cs b/Assets/Scripts/Util/AnimationHelpers.cs index 6dd548543..ce77a1513 100644 --- a/Assets/Scripts/Util/AnimationHelpers.cs +++ b/Assets/Scripts/Util/AnimationHelpers.cs @@ -66,8 +66,8 @@ namespace HeavenStudio.Util if (!double.IsNaN(startBeat)) { var cond = Conductor.instance; var animClip = Array.Find(anim.runtimeAnimatorController.animationClips, x => x.name == animName); - double animLength = cond.GetBeatFromSongPos(cond.GetSongPosFromBeat(startBeat) + animClip.length); - pos = cond.GetPositionFromBeat(startBeat, animLength - startBeat) * timeScale; + double animLength = cond.SecsToBeats(animClip.length, cond.GetBpmAtBeat(startBeat)); + pos = cond.GetPositionFromBeat(startBeat, animLength) * timeScale; } else { Debug.LogWarning("DoScaledAnimationFromBeatAsync()'s startBeat was NaN; using DoScaledAnimationAsync() instead."); }