- Home /
Animator idle minimal delay
I have the following animator for rotating a column 45 degrees: It rotates the columnd depending on the parameter "Repetitions". If Repetitions is negative, it executes the same animation but with speed = -1 instead of 1. It goes from "Do Nothing" to the rotations states if "Repetitions" are Greater (or Less in reverse case) than 0, with Exit Time unchecked. Both Rotate and Reverse Rotate states have a StateMachinBehaviour script that does:
animator.GetParameter("Repetitions")--; //(or ++ in reverse case).
So, in this way, if I want to run 8 rotations, I simply set the parameter from script. But it takes 8 times as long. So, to avoid this duration, each time I set "Repetitions", I do:
myAnimator.SetInteger("Repetitions", 8);
myAnimator.speed = myAnimator.speed * 8;
In this way, it should finish the 8 animations in the same fixed time that only 1 animation. But it isn't happening. If I set 2 different columns and I rotate the first once and the second twice, there is a minimal delay of 0,02s. It may seem invaluable, but 1 rot vs 8 rots accumulate a delay of 0,1s, and so on. I have measured this delay in the previous StateMachinBehaviour, by doing:
animator.GetParameter("Repetitions")--; //(or ++ in reverse case).
if (animator.GetInteger("Repetitions") == 0)
Debug.Log(animator.gameObject.name + " finishes rotation(s) in moment " + Time.time);
The Rotation > Do Nothing transitions are configured in this way: So, I've already set ExitTime = 0, etc. And Do Nothing > Rotations transitions are configured in this way: So, I've even already set Interruption Source to Next State, even when this is not needed. How could I avoid this delay? Any ideas?