Goal: to flip the 2D character sprite/animation based on aiming and moving.
Immediate goal: to have the animation set to “dodge right” even if (Aim Horizontal < 0)
Problem: for some reason if ( Aim Horizontal < 0 && Move Horizontal < 0 && isDodging) the animation is still playing the dodge animation as dodging right
Current code:
//Flipping animation direction
if (usingController)
{
if (player.GetAxis("Aim Horizontal") < 0)
{
if (!isDodging)
{
transform.localScale = new Vector3(-1f, 1f, 1f);
gunArm.localScale = new Vector3(-1f, -1f, 1f);
}
else
{
if (player.GetAxis("Move Horizontal") < 0)
{
transform.localScale = new Vector3(-1f, 1f, 1f);
gunArm.localScale = new Vector3(-1f, -1f, 1f);
}
else
{
transform.localScale = Vector3.one;
gunArm.localScale = Vector3.one;
}
}
}
if (player.GetAxis("Aim Horizontal") > 0)
{
transform.localScale = Vector3.one;
gunArm.localScale = Vector3.one;
}
Vector2 shootingDirection = crosshairCont.transform.localPosition;
shootingDirection.Normalize();
angle = Mathf.Atan2(shootingDirection.y, shootingDirection.x) * Mathf.Rad2Deg;
}
Maybe my logic is off. What am I doing wrong here?