- Home /
Smooth transition with Animator.Play or similar?
So we can make a smooth transition with animator easily 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
Answer by IamAnewUser · Aug 04, 2018 at 08:22 PM
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).
If you are stupid so I am. I went through the docs many times looking for this and never noticed CrossFade method. Probably because I expected a name like Play, Start, SetState, etc.
With "Make sure to check for Animator.IsInTransition before using crossfade", what do you mean? Can you give me an example? Because i want to use crossfade but it works like Animator.Play just as you said
Your answer
Follow this Question
Related Questions
Animator won't let me add transitions 1 Answer
Create animation transitions via script. 0 Answers
Animator animation transition twitch at the start 1 Answer
unwanted delay between animations 5 Answers