I’m doing the 2D cahracter Controller tutorial and I am at the part where I am trying to get my animation to switch from Idle to Run when my character moves. My character moves fine, but the animation does not switch to Run. Looking at the Animator window while the charater is moving, the float parameter “speed” is not changing at all. I am assuming the problem is that the absolute value of “move” is not being passed into Speed to trigger the animation switch. I have rewatched the tutorial a bunch of times and cannot figure out what I did wrong! Thank you in advance for your help!!! My script is below:
using UnityEngine;
using System.Collections;
public class TomControllerScript : MonoBehaviour
{
public float maxSpeed = 10f;
bool facingRight = true;
Animator anim;
void Start ()
{
anim = GetComponent();
}
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;
}
}