Hello
I was trying to add an animation transition to my character so have written some code:
void Update()
{
Vector3 characterScale = transform.localScale;
if (Input.GetKey(KeyCode.A))
{
animator.SetFloat("speed", velocity);
characterScale.x = 1;
transform.Translate(Vector2.right * Time.deltaTime * velocity);
}
else animator.SetFloat("speed", 0);
if (Input.GetKey(KeyCode.D))
{
animator.SetFloat("speed", velocity);
characterScale.x = 1;
transform.Translate(Vector2.right * Time.deltaTime * velocity);
}
else animator.SetFloat("speed", 0);
if (Input.GetKeyDown(KeyCode.Space) && Cground == true)
{
rb.AddForce(new Vector2(0f, jumpheight), ForceMode2D.Impulse);
Cground = false;
}
transform.localScale = characterScale;
}
heres my animation controller:
The Problem
My problem is that the speed parameter will only work with the animation transition when walking to the right by pressing D. if i then press A to walk to the left my character sprite flips, he moves but he wont transition to the run animation. I have no idea why and i would be very happy for any help =).