I cant get animation to work

I have the states linked up with the parameter of speed and I followed the tutorial on unity website for 2d character controller and my character moves but does not play the run animation. I dont kno if im using the SetFloat wrong but please help if u can thanks.

public float maxSpeed = 10f;
bool facingRight = true;
Animator anim;

// Use this for initialization
void Start () 
{
	anim = GetComponent<Animator>();
}

// Update is called once per frame
void FixedUpdate () 
{
	float move = Input.GetAxis ("Horizontal");

	anim.SetFloat("speed", Mathf.Abs(move));

	rigidbody2D.velocity = new Vector2 ( move * maxSpeed, rigidbody2D.velocity.y);

	if(move> 0 && !facingRight)
		Flip ();
	else if (move < 0 && facingRight)
		Flip ();
}

void Flip()
{
	facingRight = !facingRight;
	Vector3 theScale = transform.localScale;
	theScale.x *= -1;
	transform.localScale = theScale;
	
}

I think you need to set speed in your script to uppercase. You have:

 anim.SetFloat("speed", Mathf.Abs(move));

and you need and uppercase S (if you’re following the video):

 anim.SetFloat("Speed", Mathf.Abs(move));

Hope this helps :slight_smile:

In the animator editor have you inserted a parameter called Speed or speed if not do that and that should trigger the your line:

 anim.SetFloat("speed", Mathf.Abs(move))

It should look something like this in your animator