0
\$\begingroup\$

I was playing around with Unity and its 2D Animator. When I press a Button now (to play for example the walk left Animation) it takes about 1 sec to begin the animation and same when I release the button to stop it. It's the same problem with every other animation.

Here's my Player Movement Controller:

using System.Collections;
using UnityEngine;

public class Player_Movement : MonoBehaviour {

public float speed = 10;
float old_pos;
float old_height;

void Start()
{
    old_pos = transform.position.x;
    old_height = transform.position.y;
}

void FixedUpdate()
{

    float h = Input.GetAxisRaw("Horizontal");
    float v = Input.GetAxisRaw("Vertical");


    Vector2 dir = new Vector2(h, v);
    GetComponent<Rigidbody2D>().velocity = dir.normalized * speed;

    GetComponent<Animator>().SetBool("isWalkingLeft", (h < 0));

    GetComponent<Animator>().SetBool("isWalkingRight", (h > 0));
  }
}

The problem also occurs when I switch directions and the animation should instantly switch over.

\$\endgroup\$
2
  • \$\begingroup\$ Can you show us a screenshot of your animator controller graph, and the animation state configuration parameters for one of your walk animations? It sounds like the animation has been set to play to completion before considering a transition to a different state. \$\endgroup\$ Commented Dec 12, 2016 at 19:39
  • \$\begingroup\$ Sure, will do that when I'm Back home again! \$\endgroup\$ Commented Dec 13, 2016 at 7:27

1 Answer 1

1
\$\begingroup\$

The default setting for a animation transition in unity, is to blend the animation sheets. In 2D, for most cases, this is not what you want.enter image description here

From the sounds of it, you do not want to have a transition period between the two animations. What you will want to do is set your transition duration to 0, and remove the check from "Has Exit Time".

\$\endgroup\$

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.