How to make it each time when I switch between animations start from Idle state?

I have a dance game and I want to smooth transitions… I want somehow to make each time I click button start it from Idle state

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Robber : MonoBehaviour {
public Animator anim;

// Start is called before the first frame update
void Start()
{
anim = GetComponent ();
}

// Update is called once per frame
void Update()
{
if (Input.GetKeyDown (“0”))
{
print (“Idle”);
anim.Play (“Idle”, -1, 0f);
}

if (Input.GetKeyDown (“1”))
{
print (“Slowdance”);
anim.Play (“slow_dance”, -1, 0f);
}

if (Input.GetKeyDown (“2”))
{
print (“Middance”);
anim.Play (“Mid_dance”, -1, 0f);
}

if (Input.GetKeyDown (“3”))
{
print (“Fast_dance”);
anim.Play (“Fast_dance”, -1, 0f);
}
}
}

Use CrossFade or CrossFadeInFixedTime instead of Play to get smooth transitions.

1 Like

thank u : )

https://www.youtube.com/watch?v=0jCvZP86NTQ
video if someone have the same problem