diff --git a/JotunnModStub/Trenta/TrentaMuspell.cs b/JotunnModStub/Trenta/TrentaMuspell.cs index 9b1a6bb..4499faf 100644 --- a/JotunnModStub/Trenta/TrentaMuspell.cs +++ b/JotunnModStub/Trenta/TrentaMuspell.cs @@ -305,28 +305,39 @@ namespace RacesOfValheim } private const string IdleClip = "Unarmed Idle"; - private const float IdleRestartAt = 0.9f; - private const float IdleCrossFade = 0.2f; /// /// Keeps the idle going. The Elder's "Unarmed Idle" clip is not a looping clip (dumpanim: /// loop=False, 1.90s), so after the stand-up or any attack the form played it once and /// froze on its last frame. The boss never showed it, being hardly ever idle; a player in /// the form is idle most of the time. The clip's flag lives in the game's asset, so the - /// state is restarted from here instead, cross-faded into itself just before its end so - /// the seam does not show. + /// state is restarted from here instead, once it has run to its end. + /// + /// The idle shares a locomotion blend tree with the four Swagger Walk clips, so the clip + /// list for the state holds all of them and the idle is not necessarily first: it is found + /// by name and must be carrying most of the weight, which is what "standing still" means. + /// Play and not CrossFade: Unity can ignore a cross-fade from a state into itself, and + /// the first version of this did exactly nothing for that reason. /// private void LoopIdle() { if (formAnim.IsInTransition(0)) return; - AnimatorClipInfo[] clips = formAnim.GetCurrentAnimatorClipInfo(0); - if (clips.Length == 0 || clips[0].clip == null || clips[0].clip.name != IdleClip) return; + bool idle = false; + foreach (AnimatorClipInfo info in formAnim.GetCurrentAnimatorClipInfo(0)) + { + if (info.clip != null && info.clip.name == IdleClip && info.weight >= 0.5f) + { + idle = true; + break; + } + } + if (!idle) return; AnimatorStateInfo state = formAnim.GetCurrentAnimatorStateInfo(0); - if (state.normalizedTime < IdleRestartAt) return; + if (state.normalizedTime < 1f) return; - formAnim.CrossFadeInFixedTime(state.fullPathHash, IdleCrossFade, 0, 0f); + formAnim.Play(state.fullPathHash, 0, 0f); } private static void TrySet(System.Action set)