Animation transition

Updated on November 17, 2017 in Unity
Share on Facebook0Tweet about this on TwitterShare on Google+0Share on Reddit0
0 on November 17, 2017

I followed the code exactly and every setting in unity but my animation doesn’t change when i start moving.
Here is the code: 

 

using UnityEngine;

 

public class playerControl : MonoBehaviour {

 

public float maxSpeed;
Rigidbody2D RB;
Animator Anim;
bool facingRight;

 

void Start ()
{
RB = GetComponent();
Anim = GetComponent();
}

void FixedUpdate () 
{
float move = Input.GetAxis(“Horizontal”);

 

Anim.SetFloat(“SPEED”, Mathf.Abs(move));

 

RB.velocity = new Vector2 (move * maxSpeed, RB.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;
}
}
any ideas what is wrong with it?

  • Liked by
Reply