So my animations don't transition right. I have a 2d top down prototype project and animations for 4 directional movement and an idle position. Right now i have the movement set up so the right animation activates when the player moves in one of 4 directions. problem is that the walking animation does not stop when the player stops, it doesn't transition over to the idle animation.
My animation controller looks like this:
The parameter between the animations are an integer that signals which direction needs to play, from 0 to 3. I have been messing around with a speed float parameter, but I don't really know how to get it to work.
if (Input.GetKey (KeyCode.D))
{
GetComponent<Rigidbody2D>().velocity = new Vector2(moveSpeed,GetComponent<Rigidbody2D>().velocity.y);
animator.SetInteger("Direction", 2);
animator.SetFloat("MoveSpeed", 0);
}
if (Input.GetKey(KeyCode.A))
{
GetComponent<Rigidbody2D>().velocity = new Vector2(-moveSpeed, GetComponent<Rigidbody2D>().velocity.y);
animator.SetInteger("Direction", 0);
animator.SetFloat("MoveSpeed", 0);
}
if (Input.GetKey(KeyCode.W))
{
GetComponent<Rigidbody2D>().velocity = new Vector2(GetComponent<Rigidbody2D>().velocity.x, moveSpeed);
animator.SetInteger("Direction", 1);
animator.SetFloat("MoveSpeed", 0);
}
if (Input.GetKey(KeyCode.S))
{
GetComponent<Rigidbody2D>().velocity = new Vector2(GetComponent<Rigidbody2D>().velocity.x, -moveSpeed);
animator.SetInteger("Direction", 3);
animator.SetFloat("MoveSpeed", 0);
}
Here is my movement code if it helps.
If I'm missing something important that you need to help me, please tell me.
