Smooth transition with Animator.Play or similar?

So we can make a smooth transition with animator easily 122121-screenshot-158.png but can this be applied via script with something like Animator.Play?

For example, this code does not use any transition and just jumps right into the first keyframe of “2”

if (Input.GetMouseButtonDown(0)) {
    GetComponent<Animator>().Play("2");
}

Thank you

1 Like

Ok now I’m having an “I’m stupid” moment.
So it’s surprisingly simple, Animator.CrossFade is the solution.
Just make sure to check for Animator.IsInTransition before using crossfade or else it will work like Animator.Play (it will not have a smooth transition).

great share thank you. For us “The Stupid community”