This commit is contained in:
NotAKidoS 2023-03-24 20:50:21 -05:00
parent 9cc62a961c
commit 3a3cb1879c
2 changed files with 10 additions and 13 deletions

View file

@ -27,17 +27,14 @@ public class BadAnimatorFix : MonoBehaviour
{
AnimatorStateInfo stateInfo = animator.GetCurrentAnimatorStateInfo(layerIndex);
AnimatorTransitionInfo transitionInfo = animator.GetAnimatorTransitionInfo(layerIndex);
// Skip if state doesn't loop or if mid-transition
if (!stateInfo.loop || transitionInfo.fullPathHash != 0) continue;
// Skip if state hasn't looped enough
if (stateInfo.normalizedTime > StateLimit)
{
float rewindOffset = (stateInfo.normalizedTime % 1f) + 10f;
animator.Play(stateInfo.fullPathHash, layerIndex, rewindOffset);
rewound = true;
}
// Skip if mid-transition
if (transitionInfo.fullPathHash != 0) continue;
// Skip if anim doesn't loop, or hasn't looped enough
if (stateInfo.normalizedTime < StateLimit) continue;
// Rewind state, with 10f as buffer, to account for reasonable use of ExitTime
float offset = 10f + (stateInfo.normalizedTime % 1f);
animator.Play(stateInfo.fullPathHash, layerIndex, offset);
rewound = true;
}
if (rewound)

View file

@ -6,7 +6,7 @@
"loaderversion": "0.5.7",
"modtype": "Mod",
"author": "NotAKidoS",
"description": "This mod occasionally rewinds animation states that have loop enabled.\n\nUnity seems to have a weird quirk where animations with loop cause performance issues after running for a long long time.\nYou'll only start to notice this after a few hours to a few days of idling.\n\nDisable loop on your 2-frame toggle clips! They cycle insanely fast and heavily contribute to this issue.",
"description": "This mod occasionally rewinds animation states that have loop enabled.\n\nUnity seems to have a weird quirk where *sometimes* animations with loop cause performance issues after running for a long time.\nYou'll only start to notice this after a few hours to a few days of idling.\n\nIf you don't happen to be AFK for long periods of time, you probably don't need this mod. This issue seems to be primarily caused by one-two frame animation clips meant for toggles with loop needlessly enabled.",
"searchtags": [
"bad",
"fix",