Im not sure if anyone else has had this issue.
I tried to use a custom sprite that has 8 direction animations. so i implemented four triggers, walkup, walkdown, walkleft and walkright.
The idea being that I would check the movement value and be able to check which way the player is moving, to play the appropriate animation.
The up anim works great, so does the down anim. However, when trying to walk upleft/right or down left/right the animator can not seem to use the triggers properly. Here is my code, im wondering if anyone might be able to help?
if (movement != Vector3.zero)
{
anim.SetBool(IS_WALK_PARAM, true);
WalkAnimSet(x, z);
}
else
{
anim.SetBool(IS_WALK_PARAM, false);
}
private void WalkAnimSet(float x, float z)
{
anim.ResetTrigger(IS_WALK_L_PARAM);
anim.ResetTrigger(IS_WALK_D_PARAM);
anim.ResetTrigger(IS_WALK_U_PARAM);
anim.ResetTrigger(IS_WALK_R_PARAM);
if (z != 0)
{
if (z < -0.001)
{
anim.ResetTrigger(IS_WALK_U_PARAM);
anim.SetTrigger(IS_WALK_D_PARAM);
}
else if (z > 0)
{
anim.ResetTrigger(IS_WALK_D_PARAM);
anim.SetTrigger(IS_WALK_U_PARAM);
}
}
if (x != 0)
{
if (x < -0.001)
{
anim.ResetTrigger(IS_WALK_R_PARAM);
anim.SetTrigger(IS_WALK_L_PARAM);
}
else if (x > 0)
{
anim.ResetTrigger(IS_WALK_L_PARAM);
anim.SetTrigger(IS_WALK_R_PARAM);
}
}