Unity 5 Delay in animation

4

I just created the animation to run and jump with unity, but I have a problem when the player returns to IdlePlayer's initial state, when I stop running or jump it continues for another 1 second, I've already tried decrease the frames but nothing. Here is my code below and a print of the animation configuration:

public class Player : MonoBehaviour
{


    public float velociadade;


    public Transform player ;       
    public Transform Ground;  
    public Animator animator;
    public bool isGround;
    public float force = 200f;    
    public float jumpTime = 0.5f;
    public float jumpDelay = 0.5f;      
    public bool jumped ;

    void Start ()
    {           
        animator = player.GetComponent<Animator> ();    
    }   

    void Update ()
    {
        Movimentar ();
    }

    void Movimentar ()
    {
        isGround = Physics2D.Linecast(this.transform.position,Ground.position,1<<LayerMask.NameToLayer("Plataforma"));


        animator.SetFloat ("run", Mathf.Abs (Input.GetAxis ("Horizontal")));


        if (Input.GetAxisRaw ("Horizontal") > 0) {
            transform.Translate (Vector2.right * velociadade * Time.deltaTime);
            transform.eulerAngles = new Vector2 (0, 0);
        }


        if (Input.GetAxisRaw ("Horizontal") < 0) {
            transform.Translate (Vector2.right * velociadade * Time.deltaTime);
            transform.eulerAngles = new Vector2 (0, 180);
        }




        bool up = Input.GetKeyUp(KeyCode.Space);
        if (up && isGround && !jumped)
        {               
            GetComponent<Rigidbody2D>().AddForce(transform.up * force);
            jumpTime = jumpDelay;
            animator.SetTrigger("jump");   
            jumped = true;


        }


        jumpTime -= Time.deltaTime;

        if (jumpTime <= 0 && isGround && jumped) {
            animator.SetTrigger("ground");
            jumped = false;
        }   
    }

    
asked by anonymous 15.06.2015 / 22:48

1 answer

1

This is the transition animation, that other timeline that stays in the inspector when you select a transition in the animator. Just click on the white lines with icons between one state and another, for example, in your screenshot is the line that is blue because it is selected, between 'runPlayer' and 'idlePlayer'. Notice that the inspector is displaying a timeline containing these two animations, it would be up to you to choose which part of each would be displayed during the transition.

Thepartcircledinredistheanimationthatmustoccurbetweenthetransitionfromoneanimationtoanother.

Youcanjointhebeginningandtheendtohavenoanimationandendthissecondofundueanimationforyourcase.

Thisvideoexplainsmoreabouttransitionanimation animations

    
06.03.2016 / 14:59