- Home /
Problem with animator any state and transitions
Hello,
I'm having some weird troubles using Animator state machine when it involves "Any state". Basically the transition time between "Any state" and an animation seems to be calculated from the length of the "Any state" animation. That means if i'm going from walk animation (from AnyState) to a death animation, the transition time will be faster than if i go from an idle animation which is 10x longer. That causes some heavy bad behaviours on my animations. The only way i found to "fix" this is to do without "Any state" which of course is making a big mess in my Animator state machine window. I also reduced the length of my idle animation to minimize this issue...
Do you know a proper fix? Is it possible that unity will fix this and make a fixed transition time regardless to the animation length?
Another workaround may be to use the Animator Crossfade method. The normalized time parameter can be calculated by dividing the desired crossfade length by the length of the current animator state.
float normalized = crossfadeLength / contextAnimator.GetCurrentAnimatorStateInfo(animationLayer).length;
contextAnimator.CrossFade(animHash, normalized, animationLayer, 0f);
I guess i could give it a try.. Thanks!
Edit: So far it looks like to be a great workaround! I put my transitions back to Anystate and even more than i had thanks to this.
Edit2: never$$anonymous$$d... more issues, read below
Damn, i'm still having issues i can't understand. In some occasions the animator skip the last order probably because it been called too soon after some other (at least it's the only conclusion i get) If the problem seems familiar to you please i'm struggling against this for more than a month...
Now I have a system that guarantee only one crossfade per late update(the last one) but it's still not right on (not so) rares occasions.
I fixed most of my issues by unchecking atomic on all my transitions. It seems with crossfade this option is not available so it's probably why it ignores some transitions... What do you think?
Too bad.
@meat5000 Can you please explain the reasons for that? The same that I mentionned or more?
It looks like I will follow your advice anyway and my state machine will soon looks like spaghettis again :'(
Answer by barbe63 · Jan 31, 2015 at 04:31 AM
Please... This is so dumb, look at how the lack of one option (normalize transition or atomic for crossfade) turn my state machine into hell...
And my game is far from being finished... I really can't understand what could be the purpose of setting transition time based on ... current animation length???
this is....stunning. I believe you can set the transition time by pulling those line on the time graph in the inspector when you click the tranaition arrow, hope it can help.
You can't, the transition time you set this way is for all the transition from any states and it's percentage based on the animation length. No way to set different transition time from different states in Any state, or i don't know it.
The funniest part is now I almost don't use Any state anymore, i didn't even had to set diffferent transition time for any of the transition that were causing troubles before.
That means the Any state is using length of the current animation to calculate transition time while normal transition doesn't or at least set a default time that is suitable regardless to the animation length...
Answer by AllFatherGray · Jun 27, 2015 at 12:12 AM
You can add a StateBehavior script to catch and fix the problematic values of your states.
Your answer
Follow this Question
Related Questions
Animator event at the end of transition. 2 Answers
Animator State Changing but animation changes only after one animation is complete 0 Answers
2D animations transitioning too quickly and looping before finishing 2 Answers
Mecanim animator layers 0 Answers
I cant add transition on unity animator 0 Answers