playMaker

Author Topic: [Solved] Wait for mecanim animation to finish  (Read 3322 times)

thatnzguy

  • Playmaker Newbie
  • *
  • Posts: 43
[Solved] Wait for mecanim animation to finish
« on: June 08, 2015, 11:08:24 PM »
I have a sequence of animations set up in mecanim, I want to wait for the animation to finish before doing something and then playing the next animation.

How can I wait for the currently playing animation to finish?
« Last Edit: June 08, 2015, 11:45:01 PM by thatnzguy »

thatnzguy

  • Playmaker Newbie
  • *
  • Posts: 43
Re: Wait for mecanim animation to finish
« Reply #1 on: June 08, 2015, 11:44:44 PM »
Okay I found one way to do it.

The problem I encountered was when a mecanim variable is set, the animation does not immediately goto the next state, even when the transition duration is 0.

So what I have to do is use Get Animation Current State Info to get the current Name Hash and compare it with the previous hash, when they are different then I know we're at a new state. I can then use the action again and wait for the Normalized Time to be greater than 1.

I hear this is easier in Unity 5.