diff --git a/BadAnimatorFix/BadAnimatorFix.cs b/BadAnimatorFix/BadAnimatorFix.cs index 7d47f5f..494ce52 100644 --- a/BadAnimatorFix/BadAnimatorFix.cs +++ b/BadAnimatorFix/BadAnimatorFix.cs @@ -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) @@ -45,7 +42,7 @@ public class BadAnimatorFix : MonoBehaviour PlayableExtensions.SetTime(animator.playableGraph.GetRootPlayable(0), 0); } } - + if (BadAnimatorFixMod.EntryLogging.Value) { string message = rewound ? $"Rewound animator and playable {animator}." : $"Animator did not meet criteria to rewind {animator}."; diff --git a/BadAnimatorFix/format.json b/BadAnimatorFix/format.json index e7f5445..df8fd08 100644 --- a/BadAnimatorFix/format.json +++ b/BadAnimatorFix/format.json @@ -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",