Checking how far along a animation is
Animator anim;
void Start ()
{
anim = GetComponent<Animator>();
}
...
if (!anim.GetCurrentAnimatorStateInfo(0).IsName("Attack"))
{
...
}
For my current project, I am using a Animation Controller to handle the animations of my character. With my above code, I can use the if statement to run code if the animation state isn't in 'Attack'. This runs when the character attacks, so basically, it'll only run the if statement once the attack animations ends and it transitions back to Idle.
Now this works perfectly when I want code to run during the end of a animation and just as the animation state transitions from something. For example, attacking to idle or idle to dead. But what if I wanted code to run in the middle of a animation? Let's say for example, halfway past the Attack animation. How could I modify the if statement so that it checks 50% of the Attack clip has been played before running the if statement?
Your answer
Follow this Question
Related Questions
GetAnimatorTransitionInfo(0).IsName("Any State -> otherStateName") 0 Answers
creating animator transitions using script 0 Answers
Get when animator change state 0 Answers
Animation is not playing eventhough state shows it 0 Answers
Animation start delay 0 Answers