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 <noreply@anthropic.com>
This commit is contained in:
kanym 2026-09-26 18:17:37 +02:00
commit 5bdd7200a5
3 changed files with 52 additions and 1 deletions

View file

@ -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

View file

@ -0,0 +1,47 @@
using System.Collections.Generic;
using UnityEngine;
namespace RacesOfValheim
{
/// <summary>
/// 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&lt;Character&gt;() - 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.
/// </summary>
internal static class FormFootsteps
{
private static readonly HashSet<string> logged = new HashSet<string>();
public static void Detach(GameObject form, string formName)
{
if (form == null) return;
int detached = 0;
foreach (CharacterAnimEvent cae in form.GetComponentsInChildren<CharacterAnimEvent>(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.");
}
}
}
}

View file

@ -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<Collider>())
{