Hello!
I’m writing a script which will handle monster attack. Script plays Attack animation in Animator component by trigger. I want to stop monster from moving before the animation start and resume his moves after animation ends. I wrote this so far, but agent starts before animation ends. I must add that during the fight monster may get pissed and start to move faster(animation play speed multiplier).
anim.SetTrigger("Attack");
agent.Stop();
yield return new WaitForSeconds(anim.GetCurrentAnimatorStateInfo(0).length+anim.GetCurrentAnimatorStateInfo(0).normalizedTime);
Debug.Log("Attack has ended!");
agent.Resume();
If you need something more than this code please let me know.
I would really appreciate your help
Thanks so much @marcin107
This did the work for me: yield return new WaitForSeconds(anim.GetCurrentAnimatorStateInfo(0).length+anim.GetCurrentAnimatorStateInfo(0).normalizedTime);
@marcin107 This worked for me as well: yield return new WaitForSeconds(anim.GetCurrentAnimatorStateInfo(0).length+anim.GetCurrentAnimatorStateInfo(0).normalizedTime);,@marcin107 this worked for me as well thank you
yield return new WaitForSeconds(anim.GetCurrentAnimatorStateInfo(0).length+anim.GetCurrentAnimatorStateInfo(0).normalizedTime);