- Home /
Mecanim animation transition
Hi!
I would like to make transition between 2 animation states: move and idle. Both are cyclic looped. I have a problem with that, because when I want to play just move, the character seems like it is trying to transit after every move animation cycle to idle animation. Than it returns back to move animation and after another move cycle again and so on...
What am I doing wrong?
My animator looks like this:
And my script looks like this:
if(isMoving)
animator.speed = currentSpeed.magnitude;
else
animator.speed = 1;
if(!animator.GetCurrentAnimatorStateInfo(0).IsName("move") && isMoving) {
animator.Play("move");
} else if(!animator.GetCurrentAnimatorStateInfo(0).IsName("idle") && !isMoving) {
animator.Play("idle");
}
I do not exactly know what are you asking about. I am quite beginner with mecanim. I just drag'n droped these animations and right clicked one of them and than chose $$anonymous$$ake Transition option. Nothing more. I am sure, I am missing some option or something like that but I couldn't find any tutorial, how to achieve fluent transition. I just need something like crossfade in legacy animation system.
Please don't post follow-ups/comments as ANOTHER ANSWER; that is not an Answer, that is a comment. I converted it for you.
You could make 2 tansitions to and from move in the mecanim animator rather then one. If moving, access the mecanim controller Animator.SetBool("is$$anonymous$$oving", true);
Setup and link the animator to link to the one you are talking about. It will transition back and forth based off setting the value if its moving. If its not set the animator back to false and it will transition back let me know if this is unclear and I can give more details. This is how I control my animator in mecanim ins$$anonymous$$d of using states.
Could you please post a short pseudo code similar to $$anonymous$$e? I do not completely understand the part with Animator.SetBool("is$$anonymous$$oving", true); is$$anonymous$$oving is just my own variable used in other parts of the script.