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.
This commit is contained in:
parent
b201c3a637
commit
1a461dc81b
1 changed files with 19 additions and 8 deletions
|
|
@ -305,28 +305,39 @@ namespace RacesOfValheim
|
|||
}
|
||||
|
||||
private const string IdleClip = "Unarmed Idle";
|
||||
private const float IdleRestartAt = 0.9f;
|
||||
private const float IdleCrossFade = 0.2f;
|
||||
|
||||
/// <summary>
|
||||
/// 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.
|
||||
/// </summary>
|
||||
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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue