From 7d88bc78d0387c93d416ab0a8db1dfe315611348 Mon Sep 17 00:00:00 2001 From: kanym Date: Wed, 30 Sep 2026 12:55:15 +0200 Subject: [PATCH 1/3] fix(trenta): the camera rises to the Muspell's head The form hides the player's body by shrinking its Visual to 0.001, and RaceEyeHeight reads anything that small as hidden and leaves the eye where it was, at a person's height. The Muspell now measures its head height when the clone is made and hands RaceEyeHeight that height times the form's current scale, so the camera follows the grow and shrink. --- JotunnModStub/RaceEyeHeight.cs | 20 ++++++++++++--- JotunnModStub/Trenta/TrentaMuspell.cs | 37 ++++++++++++++++++++++++++- 2 files changed, 52 insertions(+), 5 deletions(-) diff --git a/JotunnModStub/RaceEyeHeight.cs b/JotunnModStub/RaceEyeHeight.cs index 7195861..563f50d 100644 --- a/JotunnModStub/RaceEyeHeight.cs +++ b/JotunnModStub/RaceEyeHeight.cs @@ -24,7 +24,8 @@ namespace RacesOfValheim /// their eye with them, and read as a factor of 1 here, so they are left alone by /// construction. So is a player inside a borrowed form (wolf, drake, bat): those hide the /// body's renderers and leave its scale at 1, and the form's own camera handling is its - /// business. + /// business. The Trenta's Muspell is the exception: it hands over its own eye height, see + /// TrentaMuspell.TryGetEyeHeight. /// /// Applied to every player, not just the one at the keyboard. m_eye is also what a mob aims /// at, so a Dvergar's head being where the Dvergar's head is matters on every client. @@ -66,10 +67,21 @@ namespace RacesOfValheim rest.LocalPosition = eye.localPosition; } - float scale = visual.transform.localScale.y; - if (scale < MinScale) return; + Vector3 wanted; + if (TrentaMuspell.TryGetEyeHeight(player, out float formEye)) + { + // The one borrowed form that sets its own eye: the Muspell is too tall to look out + // of from a person's height. Asked before the hidden-body check below, because the + // Muspell is exactly what hides the body. + wanted = new Vector3(rest.LocalPosition.x, formEye, rest.LocalPosition.z); + } + else + { + float scale = visual.transform.localScale.y; + if (scale < MinScale) return; + wanted = rest.LocalPosition * scale; + } - Vector3 wanted = rest.LocalPosition * scale; if ((eye.localPosition - wanted).sqrMagnitude > 0.000001f) { eye.localPosition = wanted; diff --git a/JotunnModStub/Trenta/TrentaMuspell.cs b/JotunnModStub/Trenta/TrentaMuspell.cs index 2864acf..1ae8011 100644 --- a/JotunnModStub/Trenta/TrentaMuspell.cs +++ b/JotunnModStub/Trenta/TrentaMuspell.cs @@ -22,6 +22,31 @@ namespace RacesOfValheim private static GameObject currentTransformation; private static bool isTransformingSequence; + /// + /// How high the form's head sits above the player's feet at a form scale of 1, measured + /// off the clone the moment it is made. Multiplied by the form's current scale it gives the + /// eye height, so the camera rides the grow and shrink tween with the model. + /// + private static float headHeightAtScaleOne; + + /// + /// The eye height the Muspell wants for , for RaceEyeHeight. + /// + /// The form hides the player's own body by shrinking its Visual to 0.001, and RaceEyeHeight + /// reads anything that small as "hidden" and leaves the eye alone - so the camera stayed at + /// a person's eye level inside something the size of a house. The form is local only, so + /// this only ever answers for the local player. + /// + public static bool TryGetEyeHeight(Player player, out float height) + { + height = 0f; + if (!IsTransformed || currentTransformation == null || headHeightAtScaleOne <= 0f) return false; + if (player == null || player != Player.m_localPlayer) return false; + + height = headHeightAtScaleOne * currentTransformation.transform.localScale.y; + return true; + } + public static void Toggle(Player player) { if (isTransformingSequence) return; @@ -167,6 +192,14 @@ namespace RacesOfValheim currentTransformation.transform.localPosition = Vector3.zero; currentTransformation.transform.localRotation = Quaternion.identity; + // Measured here, straight off the clone, before the grow tween touches its scale. The + // head is the same bone the spike volley fires from. + Transform head = currentTransformation.transform.Find(MuspellFormBehavior.HeadPath); + float cloneScale = currentTransformation.transform.localScale.y; + headHeightAtScaleOne = head != null && cloneScale > 0f + ? (head.position.y - player.transform.position.y) / cloneScale + : 0f; + // Same reasoning as FenrirRace.ExecuteTransformation: the clone must never carry // whatever AI/gameplay component made the source a functioning boss. Component animEvent = currentTransformation.GetComponent("AnimEvent"); @@ -219,6 +252,8 @@ namespace RacesOfValheim /// public class MuspellFormBehavior : MonoBehaviour { + public const string HeadPath = "Armature/root/spine1/spine2/spine3/head"; + private Animator playerAnim; private Animator formAnim; private Transform muzzle; @@ -232,7 +267,7 @@ namespace RacesOfValheim // The spike volley should leave from the Elder's own mouth, not the (now hidden) // player's eye point underneath it. - muzzle = transform.Find("Armature/root/spine1/spine2/spine3/head"); + muzzle = transform.Find(HeadPath); } private void Update() From b201c3a6378ad9b0a7a0b84399c08a7e57c1e115 Mon Sep 17 00:00:00 2001 From: kanym Date: Wed, 30 Sep 2026 13:03:58 +0200 Subject: [PATCH 2/3] 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. --- JotunnModStub/Trenta/TrentaMuspell.cs | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/JotunnModStub/Trenta/TrentaMuspell.cs b/JotunnModStub/Trenta/TrentaMuspell.cs index 1ae8011..9b1a6bb 100644 --- a/JotunnModStub/Trenta/TrentaMuspell.cs +++ b/JotunnModStub/Trenta/TrentaMuspell.cs @@ -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; + + /// + /// 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. + /// + 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 { } From 1a461dc81b97dc3174d4ee435a52a0df09b69791 Mon Sep 17 00:00:00 2001 From: kanym Date: Wed, 30 Sep 2026 13:10:29 +0200 Subject: [PATCH 3/3] fix(trenta): restart the Muspell's idle with Play, found by weight The first loop fix never fired. The idle shares a locomotion blend tree with the Swagger Walk clips, so it is not always the first clip listed: it is now found by name with most of the weight. And a cross-fade from a state into itself can be ignored by Unity, so the state is restarted with Play once it reaches its end. --- JotunnModStub/Trenta/TrentaMuspell.cs | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) 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)