How far though my animation is, via script.

Hi, I didn’t manage to any replies last time I tried to get this one answered, I will try and explain the problem a bit better.

I wish to Play animation “A” during this state I would like the user to decide which animation will play next , B or C.
at the end of animation A playing , it should then switch to either B or C , which the user decided upon.

I need Animation A to complete before B or C starts.

Here is my Original question:

Hi, I am using Untity 4 and Mecanim to animate a non-humanoid generic object. I would like to find out at runtime, how far through a particular animation my Animator State machine is. if it is say 75% though “dance the Jig”, I would like to set a parameter and possibly make a transition to another state.

Any thoughts as I am finding it really difficult to find tutorials / info on mecanim for non-human or generic animation.

Thanks

You could create a curve for each animation that is just a straight line from 0 at the start to 1 at the end. Attach it to some parameter such as PercentComplete. Then, in your script’s update method, have a line such as

float percentComplete = anim.GetFloat("PercentComplete");

if (percentComplete >= 0.75)
{
// do some event logic to transition to another state
}