- Home /
Animation doesn't start if I set Transition Duration to 0
Hey,
I have a problem with animations. I have one animator controller and 4 animations. I want to change animation randomly after I click mouse button. I have one Integer parameter 'whichFly' and made condition in every transition.
When user click a mouse button I randomly choose in script which animation plays:
myAnimator.SetInteger ("whichFly", 11); // and so on
Animation changes good, but it stays in one single graphic frame.
This is my game object
Every animation plays fine only when I change Transition Duration to value greater than 0. But i want to change my animation immediately after user clicks a mouse. Do you know what is my problem?
Thanks.
Answer by sumeeton · Mar 31, 2015 at 11:36 AM
I'm not sure what your problem is. Are you complaining about the delay in transition when mouse click occurs? Can you show where did you put the mouse click code?
The animation shows at the screen but it look like image or photo. For example if my animation has got 8 frames it stays only at first so it looks like static photo.
Yes. It works fine (frames in animation chenge so it looks like real animation) but only when I set Transition Duration for exaple to 1 or 0.5 but I dont want to any delay
I put it into Update() function.
Hmmm... my animation has got 8 frames if I set Transition Duration in low value for exaple 0.3 it only play frames 1 and 2. If I set Transition Duration to 1.0 it plays all frames correctly 1,2,3,4,5,6,7,8
I thought Transition Duration is time between animation. Am I right?
Uncheck the Can Transition To Self in the inspector for each transition. This should solve your problem.
Sure. What is happening is that when an integer is set to say suppose 2 the transition will take place for value 2. But the value is still 2 and the transitions in your animator are from AnyState. So it keeps going from AnyState to the State you wanted continuously till you set the integer to a different value. The same will happen with that state too if the transition is from AnyState. So, we uncheck CanTransitionToSelf so that if the state is 'Fly1' we don't want to trigger it again and remains in the same state. Hope that helps.
Your answer
![](https://koobas.hobune.stream/wayback/20220613191750im_/https://answers.unity.com/themes/thub/images/avi.jpg)