How Can I have Multiple Idles using Mecanim Blend Tree

Hello all,

First of all I would just like to say I have read this post http://forum.unity3d.com/threads/mecanim-play-random-animations-in-idle-state.152489/ and it’s what got me started on this.

The problem is that the normalizedTime doesn’t seem to give me back a very useful value. I’m not exactly sure what it’s supposed to do but I thought it was going to give me the current time the animation has gone.

I was using it to try and figure out when the 2nd Idle animation ends so that I can set the randomIdle float back to 0. Is there any other ways to do this?

Also what is the best way to have it actually blend between states using this method?

Thank you.

Well I figured out a solution that I think is better. I fixed some of my if checks involving normalizedTime by doing %1.0f. But I stopped using the blendtree method because I would then have to do manual blending from RandomIdle 0-1 over a certain amount of time.

I just decided to delete the blend tree and add another Idle state in the layer, then have Idle0 transition to Idle1 when RandomIdle=1.0f (basically a bool now). Then both Idles can all transition to the other animation states (walk/run etc) but all the other states only trans back to idle0. Also I have Idle1 trans back to Idle0 with the exit time condition. This makes it actually blend back to the first idle w/o me having to do anything.

idleTime -= Time.deltaTime;
		if (idleTime < 0.0f)
		{
			anim.SetFloat("RandomIdle",1f);

		}


		if ( anim.GetFloat("RandomIdle")==1.0f && anim.GetCurrentAnimatorStateInfo (0).normalizedTime%1.0f >= 0.9f) 
		{
			Debug.Log("R I 0");
			anim.SetFloat("RandomIdle",0f);
			idleTime=timeUntilNewIdle;
		}

there is all the code to get it to work. The only small issue left to fix is idleTime is still counting down even when the player isn’t idling. Should be an easy fix to figure out though.

Thanks.