- Home /
Stop Animation State in Animator from Speeding Up after Playing it a Second Time?
Unity version 5.4.0f3
Hello Unity Answers community! I'm having this problem involving the switching between animation states using booleans and the transition lines without changing the speed of the animation state. What I mean by that is when I start the scene, the first animation state plays which is the default entry/idle animation for a couple of set seconds using a script with a coroutine, then in the script it sets the bool for playing the idle animation to false and sets a bool for playing the second animation state to true.
So it switches between states and plays fine, but when the script restarts the coroutine just after changing the booleans back to the way they were at the start of the script. the idle/entry animation plays faster than what it did in the beginning. The second animation does not change it's speed, only the first idle animation. It doesn't keep getting faster, but it's second time replaying is faster than it's first, I'm almost sure of it. Does anyone have any idea what might be causing this? I've attached a screenshot of how my animator for my game object looks like, and here's the script I'm using to activate the booleans:
Animator anim;
// Use this for initialization
void Start () {
}
// Use this for initialization
void OnEnable () {
anim = GetComponent<Animator> ();
StartCoroutine (AnimStart ());
}
IEnumerator AnimStart()
{
yield return new WaitForSeconds (2.4f);
anim.SetBool ("Beat1", false);
anim.SetBool ("Beat2", true);
yield return new WaitForSeconds (3.7f);
anim.SetBool ("Beat2", false);
anim.SetBool ("Beat1", true);
yield return new WaitForSeconds (1f);
StartCoroutine (AnimStart ());
}
Any help is appreciated.
Your answer
Follow this Question
Related Questions
Jump animation anticipation 2 Answers
Add a bool to animator & activate by key press 1 Answer
Animator parameter stuck as True 4 Answers
Handling Animation and movement speed 0 Answers
Problem adding individual clip speed 2 Answers