fix(fenrir): the Ulv sleeps when the player sits
Sitting now zeroes the form's speed. The seated player's Animator keeps a forward_speed above zero, which kept the Ulv in its Walk clip on the spot and out of reach of its Sleep state, which leaves from idle. The debug log showed it: sitting, sleeping=true, clip 'Walk'.
This commit is contained in:
parent
4cb6da801b
commit
9cf3f5386c
1 changed files with 10 additions and 3 deletions
|
|
@ -66,8 +66,15 @@ namespace RacesOfValheim
|
|||
// sneaking in a form slid across the ground in the idle pose. Crouched, the player moves
|
||||
// at sneaking speed, and the creature's controller picks its walk for a speed that low:
|
||||
// the sneak a player asked for, from animations the creature already has.
|
||||
try { form.SetFloat("forward_speed", grounded ? playerAnim.GetFloat("forward_speed") : 0f); } catch {}
|
||||
try { form.SetFloat("sideway_speed", grounded ? playerAnim.GetFloat("sideway_speed") : 0f); } catch {}
|
||||
//
|
||||
// Sitting reads as still too. The seated player's own Animator keeps a forward_speed that
|
||||
// is not zero, and passed through it kept the Ulv in its Walk clip - on the spot, and out
|
||||
// of reach of its Sleep state, which only leaves from idle. Seen in the log: sitting,
|
||||
// sleeping=true, clip 'Walk'.
|
||||
bool sitting = IsSitting(player);
|
||||
bool still = !grounded || sitting;
|
||||
try { form.SetFloat("forward_speed", still ? 0f : playerAnim.GetFloat("forward_speed")); } catch {}
|
||||
try { form.SetFloat("sideway_speed", still ? 0f : playerAnim.GetFloat("sideway_speed")); } catch {}
|
||||
|
||||
// Sitting puts the creature to sleep, on the "sleeping" bool its own MonsterAI uses - the
|
||||
// Ulv curls up. IsSitting reads the animator's state, which is replicated, so it is right
|
||||
|
|
@ -87,7 +94,7 @@ namespace RacesOfValheim
|
|||
(hasSleeping ? "sitting puts it to sleep." : "sitting keeps it idle."));
|
||||
}
|
||||
}
|
||||
if (hasSleeping) form.SetBool("sleeping", IsSitting(player));
|
||||
if (hasSleeping) form.SetBool("sleeping", sitting);
|
||||
|
||||
return grounded;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue