I am new working in 2D games. And i am making the animation run. When my character is running and i change the directions fast. A little moment it changes to idle animation. And i know how to fix it.
Here you can see it better: https://gph.is/2RrBaYu
Thanks a lot!!!
void movePlayer()
{
Vector2 v = new Vector2(0, rb.velocity.y);
if (Input.GetAxisRaw("Horizontal") > 0.1f)
{
v.x = movementSpeed * Time.deltaTime ;
}else if (Input.GetAxisRaw("Horizontal") < -0.1f)
{
v.x = -movementSpeed * Time.deltaTime;
}
if(v.x > 0)
{
spr.flipX = false;
}
else if(v.x < 0)
{
spr.flipX = true;
}
rb.velocity = v;
animator.SetFloat("Run", Mathf.Abs(Input.GetAxisRaw("Horizontal")));
}