Animation Jump problems

I have an animation that contains the jump, fall, landing of my player. But I split the animation in 3 clips, so I can use the falling separated. So I do the following:

animation.AddClip(JumpClip, "Jumping",0,16);
	animation.AddClip(JumpClip, "Falling",17,26);
	animation.AddClip(JumpClip, "Landing",27,31);

After that in my movement script I have a call to 2 functions that are called DidJump, DidLand. So I put them in this way:

function DidJump () {
	// We want to play the jump animation queued,
	// so that we can play the jump animation multiple times, overlaying each other
	// We dont want to rewind the same animation to avoid sudden jerks!
		animation["Jumping"].speed=0.1;
	animation["Jumping"].layer =1;
	animation["Jumping"].enabled = false;
	animation["Jumping"].weight=1;
	animation["Jumping"].wrapMode = WrapMode.Clamp;
	if(CaneHandle==false)
	animation.CrossFadeQueued("Jumping",0.1,QueueMode.PlayNow);
	else
	animation.CrossFadeQueued("Jump+Cane", 0.1 , QueueMode.PlayNow);
yield WaitForSeconds(0.26);
	SendMessage("Fall", SendMessageOptions.DontRequireReceiver);
}
function Fall(){
	animation["Falling"].speed=0.15;
	animation["Falling"].layer = 2;
	animation["Falling"].enabled = false;
	animation["Falling"].weight=1;
	animation["Falling"].wrapMode = WrapMode.Clamp;
animation.CrossFadeQueued("Falling",0.1,QueueMode.PlayNow);
yield WaitForSeconds(0.2);


}
function DidLand () {
	animation["Landing"].speed=0.3;
	animation["Landing"].layer = 3;
	animation["Landing"].enabled = false;
	animation["Landing"].weight=1;
	animation["Landing"].wrapMode = WrapMode.Clamp;
	
animation.CrossFadeQueued("Landing",0.1,QueueMode.PlayNow);

What I want is, that if the jump is execute the clip Jumping will be played once, when this clip is over the clip falling will be played till it reaches the end. And the landing clip will be played only when it reaches the floor. But I cant make it worked. Could someone help me?

linkthewise - … just out of curiosity, why are you playing your animations so slowly? (and not even at a constant speed to each other)

As for your problem, you haven’t mentioned where it doesn’t work. Your code looks clunky to me, but as far as I can tell, something calls the characters DidJump() function, the jump animation plays, then the fall animation plays.

Presumably something else will then call DidLand() when it detects the ground contact.

What part is giving you trouble?

I have two scripts, one for movement and one for animation, the movement send a message of jumping and sends the landing. Well the speed I was testing it, cuz the animation only have 30 frames. I test the landing function and the jump function. And they worked fine, the problem is that I cant play animations in a correct way, for some reason the animation dont respect the speed I gave, and I cant find a way to stop the falling animation in the last frame so it keeps in that way till the player hits the ground. I’m a noob and I dont know really how animations work in unity. So any help its good to me.

Okay, first of all you seem to be doing some redundant stuff, for instance, your fall animation code :-

animation["Falling"].speed=0.15; 
animation["Falling"].layer = 2; 
animation["Falling"].enabled = false; 
animation["Falling"].weight=1; 
animation["Falling"].wrapMode = WrapMode.Clamp; 
animation.CrossFadeQueued("Falling",0.1,QueueMode.PlayNow);

There’s not much point disabling the animation and setting its weight to 1 since your crossfade is going to enable the animation and set it’s weight to 0. You also set the wrapMode explicitly each time, why not set it the way you want it in the Inspector?

Using CrossFadeQueued with PlayNow seems strange in this situation. I sort of understand why you might use it on the jump, but in this case you could strip the code back to :

animation["Falling"].speed=0.15; 
animation.CrossFade("Falling",0.1);

As for the speed of your animations, you’re going to have to be clearer. What isn’t it respecting? You have very small values like 0.15, does your animation play very slowly? Normal speed? Too fast?

And what do you want to happen on the last frame of the falling animation? Right now you have it clamped, so it should reach the last frame and freeze like that until it’s interrupted. Is that happening, or is something else occurring?

As I said before I cant specify in the inspector that cuz I’m making those clips in the script, with the function AddClip, so I manage to split the animation, thats why I have to specify wrapmode in the code. And the animation doesnt respect the speed that I consider slow, so it means that the animation its going fast when it should go slow.
I will try what you said above, and thanks for the help Sycle.

Edit: Almost everything is working, the only problem I’m having is that when the player lands if I press and hold a key the player stays in the las frame of landing sequence. Does anyone know how to fix this?