I use the blending tree to control movement
}
public void UpdateAnimationValue(float verticalMovement,float horizontalMovement,bool isSprinting)
{
#region Vertical
float v =0.0f;
if(verticalMovement>0 && verticalMovement<0.55f)
{
v = 0.5f;
}else if(verticalMovement > 0.55f)
{
v = 1.0f;
}else if(verticalMovement <0 && verticalMovement >-0.55f)
{
v = -0.5f;
}else if(verticalMovement < -0.55f)
{
v = -1.0f;
}
else
{
v=0.0f;
}
#endregion
#region Horizontal
float h =0.0f;
if(horizontalMovement>0 && horizontalMovement<0.55f)
{
h = 0.5f;
}else if(horizontalMovement > 0.55f)
{
h = 1.0f;
}else if(horizontalMovement <0 && horizontalMovement >-0.55f)
{
h = -0.5f;
}else if(horizontalMovement < -0.55f)
{
h = -1.0f;
}
else
{
h=0.0f;
}
#endregion
if(isSprinting)
{
v=2.0f;
h=horizontalMovement;
Debug.Log(“Press IsSprinting,but v value not”);
Debug.Log(“v=”+v);
}
anim.SetFloat(vertical,v,0.1f,Time.deltaTime);
anim.SetFloat(horizontal,h,0.1f,Time.deltaTime);
}
The weird thing is that I can debug.log(v=2), which actually means if(isSprinting) can work
but anim.SetFloat(vertical, v , 0.1f, Time.deltaTIme) can’t work, can’t read v=2 value
That’s really strange