fix(trenta): the Muspell's idle loops instead of freezing

The Elder's "Unarmed Idle" clip is not a looping clip (loop=False,
1.90s), so after standing up or attacking the form played it once and
froze on the last frame. The state is now cross-faded into itself just
before its end while the form stands idle.
This commit is contained in:
kanym 2026-09-30 13:03:58 +02:00
commit b201c3a637

View file

@ -290,6 +290,8 @@ namespace RacesOfValheim
TrySet(() => formAnim.SetFloat("sideway_speed", playerAnim.GetFloat("sideway_speed")));
}
LoopIdle();
if (!isGrounded || !RaceInput.Allowed) return;
if (RaceInput.AttackDown(0)) // Stomp
@ -302,6 +304,31 @@ namespace RacesOfValheim
}
}
private const string IdleClip = "Unarmed Idle";
private const float IdleRestartAt = 0.9f;
private const float IdleCrossFade = 0.2f;
/// <summary>
/// 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.
/// </summary>
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;
AnimatorStateInfo state = formAnim.GetCurrentAnimatorStateInfo(0);
if (state.normalizedTime < IdleRestartAt) return;
formAnim.CrossFadeInFixedTime(state.fullPathHash, IdleCrossFade, 0, 0f);
}
private static void TrySet(System.Action set)
{
try { set(); } catch { }