diff --git a/JotunnModStub/Aswid/AswidVisuals.cs b/JotunnModStub/Aswid/AswidVisuals.cs index 8d041f9..e52ef30 100644 --- a/JotunnModStub/Aswid/AswidVisuals.cs +++ b/JotunnModStub/Aswid/AswidVisuals.cs @@ -396,7 +396,15 @@ namespace RacesOfValheim // Ask the rig which way it faces, once, and round the answer to the skull's own axes - // see DvergarVisuals.BuildEyes for why the raw, unrounded measurement puts the eyes at // the jaw instead of the eye line. - Transform root = headBone.root; + // + // player.transform, NOT headBone.root. headBone comes off VisEquipment.m_bodyModel's + // own bone array, and walking .root from there does not reliably land back on the + // player - the eyes came out wrong on every single build, not just an unlucky one, which + // is what a bad-timing read (the guard above already handles that) would look like. + // A CONSISTENTLY wrong answer means a consistently wrong reference, not a bad moment to + // ask it in. DvergarVisuals.BuildEyes already reads player.transform directly for + // exactly this reason; this now matches it. + Transform root = player.transform; EyeFrame frame = holder.AddComponent(); frame.LocalForward = SnapToAxis(headBone.InverseTransformDirection(root.forward)); frame.LocalUp = SnapToAxis(headBone.InverseTransformDirection(root.up)); diff --git a/JotunnModStub/Sverm/SvermVisuals.cs b/JotunnModStub/Sverm/SvermVisuals.cs index 9e5b79c..c912e5e 100644 --- a/JotunnModStub/Sverm/SvermVisuals.cs +++ b/JotunnModStub/Sverm/SvermVisuals.cs @@ -192,7 +192,20 @@ namespace RacesOfValheim return; } - if (eyes == null) eyes = BuildEyes(headBone); + if (eyes == null) + { + // See AswidVisuals.ApplyEyes / DvergarVisuals.ApplyEyes for the full reasoning - + // BuildEyes takes a one-time reading of the head bone's pose to work out which way + // the skull faces, and caches it for as long as the eyes exist. Sitting, attached, + // mid-attack or asleep, the head can be turned away from the body's own forward at + // that instant, which is how the snap-to-axis has picked the wrong side and left + // eyes behind the skull before. + if (player.IsAttached() || player.IsAttachedToShip() || player.InAttack() || player.IsSleeping()) + { + return; + } + eyes = BuildEyes(player, headBone); + } if (eyes == null) return; // already logged once by the resolver PlaceEyes(player, headBone, eyes); @@ -256,7 +269,7 @@ namespace RacesOfValheim } } - private static Transform BuildEyes(Transform headBone) + private static Transform BuildEyes(Player player, Transform headBone) { Shader glow = ResolveGlowShader(); if (glow == null) return null; @@ -270,7 +283,12 @@ namespace RacesOfValheim // Ask the rig which way it faces, once, and ROUND the answer to the skull's own axes. // The raw, unrounded measurement puts the eyes on the jaw - DvergarVisuals found that // out first. - Transform root = headBone.root; + // + // player.transform, NOT headBone.root - walking .root up from a bone in + // VisEquipment.m_bodyModel's own array does not reliably land back on the player, and + // gave a wrong answer on every single build rather than an occasional bad-timing one. + // DvergarVisuals.BuildEyes already reads player.transform directly; this now matches it. + Transform root = player.transform; EyeFrame frame = holder.AddComponent(); frame.LocalForward = SnapToAxis(headBone.InverseTransformDirection(root.forward)); frame.LocalUp = SnapToAxis(headBone.InverseTransformDirection(root.up));