So here, Crossfade is doing nothing. I see people have fixes like set wrapMode to something but what is never explained is WHY. The documentation lists something pretty much the same, only it isn’t as cut and paste as what it says works. Crossfade shouldn’t have any hidden settings to make it work. Pretty much,
void Awake()
{
//this.animation["SL_H_C"].weight = 1.0f;
//this.animation["RL_H_C"].weight = 1.0f;
this.animation["SL_H_C"].wrapMode = WrapMode.Loop;
this.animation["RL_H_C"].wrapMode = WrapMode.Once;
this.animation["SL_H_C"].layer = 0;
this.animation["RL_H_C"].layer = 1;
}
void Update()
{
if (Input.GetAxis("Vertical") > 0.2f)
{
this.animation.CrossFade("SL_H_C");
}
if (Input.GetAxis("Horizontal") > 0.2f)
{
this.animation.CrossFade("RL_H_C");
}
Debug.Log("SL IS: " + this.animation["SL_H_C"].weight.ToString("0.0000"));
Debug.Log("RL IS: " + this.animation["RL_H_C"].weight.ToString("0.0000"));
}
The confusion here is two things.
“SL_H_C” should be 0 when “RL_H_C” is fully 1. This isn’t the case. “SL_H_C” never goes down from 1 and once “RL_H_C” hits 1, it immediately goes down to 0. To my belief, “RL_H_C” should stick to having full control and the loop should stop since it contributes 0 weight to the animation. However, this is not the case here.