Animations Imported From Blender Get Stuck In a RPG.
I'm using the legacy animation type. I rig my characters in Blender.
If i set the attack speed too high then the attacking animation has a chance to get stuck.
Sometimes enemies also get stuck even with low attack speed.
The type of code for animations i use is this. I use GetComponent().Play("Attack"); to start an animation.
if (attack == 1 && GetComponent<Animation>()["Attack"].time>0.9*GetComponent<Animation>()["Attack"].length)
It checks if the player is attacking and if the time of the animation is higher than set then it creates an attack projectile, for example and sets the player to not attack. If not attacking then the player and enemies can usually move or start another attack.
What are reasons animations could get stuck and how to fix them? Is there maybe a better way to check, if animations are done playing?
After attacking attack = 1. It basically gets stuck in attack = 1. The time of the attack gets stuck at 0, I checked by debugging. The player can't move or do anything at that point because attack = 1 and you can only do stuff, if attack = 0. The animation might finish before the time is past 90%. For some reason it skips to the end of the animation and then resets the time to 0. Sometimes right after attacking it gets stuck.
This is what might be causing the problem but i'm not sure how to fix it. When the enemies are not visible to the camera then they are not animated correctly. I need them to also attack when they're not visible. It looks like they get stuck when they are not visible to the camera. The animation timer gets stuck from what i've seen debugging.
Animations seem to also freeze when the game is processing many things. I think i might need a coroutine but i have no idea how to set it up for animations.
Your answer
Follow this Question
Related Questions
Blender rigged empties, 0 Answers
Blender animations using multiple armatures not functioning properly 1 Answer
Rigging af 2D character, so the feet is the root 0 Answers
Animation in Blender or Unity? 0 Answers
Trouble with Humanoid Avatars 1 Answer