Animator.setFloat() not working
I got this code for animating my controller:
public void Move()
{
horizontal = Input.GetAxis("Horizontal");
vertical = Input.GetAxis("Vertical");
fVelocity = new Vector3(horizontal, 0, vertical) * moveSpeed;
rb.velocity = fVelocity;
**if (rb.velocity.x !=0)
{
Debug.Log("This print works");
anim.SetFloat("Move", 1.0f); //But this does not
}
else
{
anim.SetFloat("Move", 0f);
}** //This animation does not work
**if (rb.velocity.z != 0)
{
anim.SetFloat("Move", 1.0f);
}
else
{
anim.SetFloat("Move", 0f);
}** //This animation works perfect
if (horizontal != 0)
{
transform.forward = new Vector3(horizontal, 0, 0);
}
if (vertical != 0)
{
transform.forward = new Vector3(0, 0, vertical);
}
}
Now, i want to know why the z axis animation works perfect, but the x animation does not set the Move float. Therefore, it cant move.
Thanks for your time :)
Comment