- Home /
Finish animation before playing another one
I'm struggling to make my character stay normal. I use ThirdPersonController with Animation component. My character has "idle", "walk", "run" and "jump" animations applied. For run animation I made him "roll", because his body is spherical but whenever I release Shift(in the middle of animation), he stays in that position (e.g. legs up) and goes into idle or walking animation depending on what I'm pressing.
I really need help with that, thanking everyone in advance!!!
EDITED result of an advice from the comments
ThirdPersonController.js
// Pick speed modifier
if (Input.GetKey (KeyCode.LeftShift) || Input.GetKey (KeyCode.RightShift))
{
targetSpeed *= runSpeed;
_characterState = CharacterState.Running;
// return new WaitForSeconds(walk.animation[newRoll].lenght);
//yield WaitForSeconds (animation["newRoll"].length);
}
else if (Time.time - trotAfterSeconds > walkTimeStart)
{
targetSpeed *= trotSpeed;
_characterState = CharacterState.Trotting;
}
else
{
if(!animation.isplaying) { animation.crossfade("walk2"); }
targetSpeed *= walkSpeed;
_characterState = CharacterState.Walking;
}
this answer might be legacy animation, but is there not an anim.isplaying function ?
if(!anim.isplaying) { anim.crossfade("animname"); }
@$$anonymous$$larax now he stands still (not able to walk while doing the idle animation) untill I press walking key + shift. It does one roll animation till the end while standing on one spot and after that everything gets the same, like I explained above...
and now I'm getting constant "$$anonymous$$issing$$anonymous$$ethodException" : UnityEngine.Animation.crossfade"