Characters and sequencing animations

I have a T-Pose character and a series of up to 20 separate animations.

I can load the animations in and apply them to my t-pose using the simple crossfade commands to change animations nicely under player control.

I now need to test for the length of any particular animation which I play so I can crossfade to another animation at an appropriate moment, without a pause.

For example, I have 5 idle animations, if I try to randomly select the next idle animation to play, there is a slight pause - because I have set the wrapmode to once (not loop) so that I can test if the animation is playing or not. The issue here is once it is not playing - the slight pause causes the animations to stop between each idle (obviously!), where I really want them to smoothly crossfade without any pause in fluidity.

My thought was to set the wrapmode to loop and then simply test for the length of the animation currently playing, so I can crossfade once it has looped once. However I can’t seem to figure out how to achieve that.

Can anyone help please? Is my approach incorrect? I know there is an animation clip .length property, but I haven’t made my animations into clips as that seems a little more involved and unnecessary.

Thanks,

IPete2.

Ok - for those with the same sort of questions - I have found the answer:

Set all the animation wrapmodes to loop.

Quantum is my main character shown below.
lengthOfFade is a variable set to 0.25
QuantumAnimation is the starting name and then the current of the animation playing, in this case “idle1”

// if no animation is playing then zero all animation and get ready for a new one 	
if (animation[QuantumAnimation].time >= (animation[QuantumAnimation].length-lengthOfFade)) 
 
	{	
	 CheckForANewAnimation() ; // this starts a new animation randomly from 5 idle animations it sets my variable QuantumAnimation to a new animation name

		// crossfade to the new animation here
		animation.CrossFade(QuantumAnimation,lengthOfFade);
	}