Alright, I’m new to Unity, but have a little experience(Not much) with Java Script.
I am trying to make FPS character animations
This is what I have.
function Start ()
{
animation.wrapMode = WrapMode.Loop;
animation["Walk"].layer = 1;
animation.Stop();
}
function Update ()
{
if (Mathf.Abs(Input.GetAxis("Vertical")) > 0.1)
animation.CrossFade("Walk");
else
animation.Stop("Walk");
animation.CrossFade("Idle");
}
Everything works fine, except for some rare occasions when the hand stops before the animation is over, and his hand is idling in front of his face. I want them to switch to the idle animation all together.
So what I want is the animation to be two separate animations. When I walk I do the walking animation. When I Idle I do the Idle animation. No inbetweens.
You need to check if the length of your animation matches the length you need to specify when importing the animation. I suggest you use split animation even if it is one animation, and there you set the number of frames your animation has.
Also, I suggest you use some sort of state machine so your aren’t calling CrossFade every frame when your Input condition is true/false.
On the other hand, Crossfade will make you go from one animation to the other, so you don’t need to stop the animation or else there will be no animation to blend with. Stop and then play make sense (but the animation change won’t be smooth), but stop and cross fade do not make sense. I hope this helps.