The way the program is supposed to run is basically, a character can be running/idle and if spacebar is pressed, all movement stops and movement controls are locked through the bool "canMove". The integer shockwave is a 1-4, directly correlating to the direction 1-4 (1 = north, 2 = east, 3 = south, 4 = west). Then, the animation plays and when it is over the controls are unlocked and you can move freely.
The problem I have encountered is, I can find no way to specifically tell when the animation is ending inside of a blend tree. I cannot find a way to allow the animation to play, and then continue to unlock the controls.
Since this site won't let me post more than three links, I will have to describe the animator window. Basically I have four idle states (N, E, S, W). Each motion is a blend tree, and each state is connected with a transition purely based off of int direction.
This is where I tried adding another motion to the blend tree called shockwave, based on threshold speed (-1). This worked up until the point that I realized I would not be able to add anymore attacks or states, and that I could not tell when the animation had finished in order to unlock the controls.
void Update (){
if (Input.GetKey (KeyCode.Space)){
canMove = false;
direction = animator.GetInteger ("Direction");
animator.SetFloat ("Speed", 0.0f);
if (direction == 1){
animator.SetInteger("Shockwave", 1);
animator.SetFloat ("Speed", -1.0f);
//find a way to detect that the attack animation is done.
//continue and allow movement
canMove = true;
}
}
else if (direction == 2){
animator.SetInteger ("Shockwave", 2);
//if(!anim.IsPlaying ("character_shockwave_2")){
//canMove = true;
//}
}
else if (direction == 3){
animator.SetInteger ("Shockwave", 3);
//if(!anim.IsPlaying("character_shockwave_3")){
// canMove = true;
//}
}
else if (direction == 4){
animator.SetInteger ("Shockwave", 4);
//if(!anim.IsPlaying("character_shockwave_4")){
//canMove = true;
//}
}
Attempted solutions:
I have tried to use waitforseconds(x), and just wait for the attack animation to finish, and then after that amount of seconds I would set the canMove bool to true. For whatever reason, I cannot get this to work.
I have also tried to directly find if the animation is done playing through a few different ways, but I learned that the blend tree does not allow this.
The only solution I have thought might work is actually manually playing all animations through code alone. (Would require re writing the entire program).
If any further code is needed, I can supply it.

