From 5bdd7200a58ba805f2e3860f7bc75acae9f37786 Mon Sep 17 00:00:00 2001 From: kanym Date: Sat, 26 Sep 2026 18:17:37 +0200 Subject: [PATCH] fix(fenrir): the Ulv no longer asks the player for feet called LeftHand The form's CharacterAnimEvent finds its FootStep on the nearest Character up the hierarchy, which for a form parented under the player is the player. The Ulv's Run clip names its front paws LeftHand and RightHand, a human rig has neither, and vanilla logged "FAiled to find foot" twice per stride. The form's receivers are now cut from the player's FootStep, on the local form and on the copy other players see. The footsteps stay: the hidden human animator keeps running and FootStep steps off its curve. Co-Authored-By: Claude Opus 5.5 --- JotunnModStub/Fenrir/FenrirRace.cs | 2 ++ JotunnModStub/Fenrir/FormFootsteps.cs | 47 +++++++++++++++++++++++++++ JotunnModStub/ZdoVisualSync.cs | 4 ++- 3 files changed, 52 insertions(+), 1 deletion(-) create mode 100644 JotunnModStub/Fenrir/FormFootsteps.cs diff --git a/JotunnModStub/Fenrir/FenrirRace.cs b/JotunnModStub/Fenrir/FenrirRace.cs index 4e55a80..5c00200 100644 --- a/JotunnModStub/Fenrir/FenrirRace.cs +++ b/JotunnModStub/Fenrir/FenrirRace.cs @@ -383,6 +383,8 @@ namespace RacesOfValheim { Component animEvent = currentTransformation.GetComponent("AnimEvent"); if (animEvent != null) Destroy(animEvent); + FormFootsteps.Detach(currentTransformation, prefabName); + // The creature's own animations carry their sounds as events; this is what hears // them. On the object that owns the Animator, because that is where Unity delivers // an animation event - for the wolf that is WolfSmooth, two levels down, not the diff --git a/JotunnModStub/Fenrir/FormFootsteps.cs b/JotunnModStub/Fenrir/FormFootsteps.cs new file mode 100644 index 0000000..d106301 --- /dev/null +++ b/JotunnModStub/Fenrir/FormFootsteps.cs @@ -0,0 +1,47 @@ +using System.Collections.Generic; +using UnityEngine; + +namespace RacesOfValheim +{ + /// + /// Stops a Fenrir form's own animations from stepping on the player's FootStep. + /// + /// The form's CharacterAnimEvent resolves its FootStep in Awake, from + /// GetComponentInParent<Character>() - and a form parented under the player finds the + /// PLAYER. So when the Ulv's 'Run' clip fires FootStep('LeftHand') and FootStep('RightHand') + /// for its front paws, vanilla looks for feet with those names on a human rig, finds none, and + /// logs "FAiled to find foot:LeftHand" twice per stride. That is the warning a user reported. + /// + /// Nothing is lost by cutting the link. The player's hidden Visual keeps animating (the hider + /// only switches renderers off), and FootStep drives its steps from that animator's footstep + /// curve, so the form already has footsteps. A form event naming a foot the player does have + /// would only play a second step on top of that one. + /// + /// CharacterAnimEvent.FootStep checks m_footStep before calling it, so nulling the field is + /// all it takes. It has to happen after Instantiate, which is when that Awake has run. + /// + internal static class FormFootsteps + { + private static readonly HashSet logged = new HashSet(); + + public static void Detach(GameObject form, string formName) + { + if (form == null) return; + + int detached = 0; + foreach (CharacterAnimEvent cae in form.GetComponentsInChildren(true)) + { + var field = HarmonyLib.Traverse.Create(cae).Field("m_footStep"); + if (field.GetValue() == null) continue; + field.SetValue(null); + detached++; + } + + if (logged.Add(formName)) + { + Jotunn.Logger.LogInfo( + $"[FenrirForm] '{formName}': {detached} animation-event receiver(s) cut from the player's FootStep."); + } + } + } +} diff --git a/JotunnModStub/ZdoVisualSync.cs b/JotunnModStub/ZdoVisualSync.cs index 686a831..93422ed 100644 --- a/JotunnModStub/ZdoVisualSync.cs +++ b/JotunnModStub/ZdoVisualSync.cs @@ -212,7 +212,9 @@ namespace RacesOfValheim m_currentFormInstance.transform.localRotation = Quaternion.identity; Component animEvent = m_currentFormInstance.GetComponent("AnimEvent"); if (animEvent != null) Destroy(animEvent); - + + FormFootsteps.Detach(m_currentFormInstance, currentForm); + // Clean up colliders on remote visuals foreach (var col in m_currentFormInstance.GetComponentsInChildren()) {