Easy help, animation control, newb inside!

Hi there, i created a building (for an rts) that has a Building,idle,working,doorOp animations.

Now, i told it to play automatically the Building anim when starting, and it plays.

Then i created a JS script for controlling the animation…well, here it is

function Start()
{
	animation["idle"].wrapMode = WrapMode.Loop;
	animation["working"].wrapMode = WrapMode.Loop;
}

function Update ()
{
	animation.PlayQueued("idle", QueueMode.CompleteOthers);
	//if (Input.GetButtonDown("Fire1"))
	//	animation.CrossFade ("working");
	//else
	//	animation.CrossFade ("idle");
		
}

In this way (with if-input commented) it regularly plays the default anim (Building) and loops “idle” when finished. It’s ok!
But if i uncomment those lines, the building anim stops at the first 10-15 frames and then starts playing the idle anim in loop.

The thing i want to know is if there is a method to control if an animation has finished playing (in my case,Building) and then starts with controls for controlling the other various animations.

It’s different from the, say, tutorial anim controls because i have this MANDATORY FIRST animation to play before i start controlling the object anims.

I also thought that i could make 2 different scripts, one for the building anim, then destroys itself and replaces with other controls, but i think there is a smoother way to do this!

Any help?
I also tried with animation[…].IsPlaying but Unity gives me error because IsPlaying is not in the “UnityEngine.AnimationState”.

Thanks for answering :smile:
Akabane

I think the Animation.PlayQueued() function might be what you are looking for.