- Home /
Animation state not playing out fully
http://www.youtube.com/watch?v=qDelGcKGtzE - video of what's going on, play in 480p+ to see the console prints
http://pastebin.com/GqLy3xQR - the javascript being used to trigger animations.
tl;dr version:
want to trigger two different kinds of lands based on how long you've been falling. the console tells me that the functions actually trigger, but the animation doesn't play. the animation works though, can trigger and play it in the editor.
if (controller.isGrounded && Timer.Timer < 1.2 && state == 5){
States.runjumpLandrun();
}
if (controller.isGrounded && Timer.Timer > 1.2 && state == 5){
States.runjumpLandroll();
}
function runjumpLandroll(){
animation.CrossFade("runjump_roll", 0.1, PlayMode.StopSameLayer);
print("land_roll");
if (Input.anyKey == false){
animation.CrossFade("runjump_idle", 0.1, PlayMode.StopSameLayer);
state = 1;
}
}
function runjumpLandrun(){
if (Input.GetKey("w")){
animation.CrossFade("runjump_run", 0.1, PlayMode.StopSameLayer);
print("land_run");
state = 2;
}
else{
animation.CrossFade("runjump_idle", 0.1, PlayMode.StopSameLayer);
state = 1;
}
}
(runjumpLandroll() doesn't start with a Input.GetKey atm, I've had that line in there before, didn't work at that time either. so I don't think that's the problem)
Hello! :) I've been trying to trigger a land_roll animation if my character falls for more than 1.2 seconds. Anything under 1.2 seconds should just result in a "normal" land.
I've got a timer that is enabled when you jump and which the controller.isGrounded function checks to see what land function to go to. I solved it with one function earlier. Just one land function that checked the timer rather than the controller.isGrounded checking and then sending us along to either function.
As you can see in the video, it works.
If the timer is less than 1.2 seconds (as it is when just jumping around on the "roof"), we're playing the normal land animations. The land-to-run and land-to-idle if you wish.
And when jumping off the "roof" the console prints out "land_roll" which is as you can see in the pastebin link, part of the function that should also trigger the roll animation.
But it doesn't.
I've tried different ways of solving this but with no success. I'm going to want to trigger yet another version of the land, if you fall for less than say half a second..hopefully the same timer workflow would work.
Anyone got a clue why the controller.isGrounded manages to trigger both "states" based on how many seconds the timer is at, but doesn't trigger the animation?
All animations work, I can trigger it separately using any other kind of input (space for example).
Thank you! :)
tried to answer it before, guess it's waiting for a moderator to verify it :)
Answer by thatanimator · Jun 06, 2012 at 05:21 PM
got it working after looking at the script for another day..
just copied the run part of the function that gets called if you're falling for less than 1.2 seconds,
function runjumpLandrun(){
if (Input.GetKey("w")){ animation.CrossFade("runjump_run", 0.1, PlayMode.StopSameLayer); print("land_run"); state = 2; } else{ animation.CrossFade("runjump_idle", 0.1, PlayMode.StopSameLayer); state = 1; }
}
and put the if (Input.GetKey("w")){ in the "longer than 1.2"-function and replaced the animation..
wonder what could have been wrong, code was basically the same.
oh well, fixed it! :)
Your answer
Follow this Question
Related Questions
Animator switches animation without trigger 0 Answers
Mechanim state triggers twice 1 Answer
Strange issue changing the animation state 0 Answers
trigger animation problems 2 Answers