Animation sequence?

Hello,

I was wondering if there is a way to do this: When I hit “MouseButton(1)” animation 1 plays, then the next time I hit “MouseButton(1)” animation 2 plays, an so on for 4 animations, then its starts back at animation 1 after animation 4 is complete.

Thanks for any input into this subject,

Hi there!

I cooked you a script to get you started:

#pragma strict

/* 	Animation Switching
	- Put this script on the object you want to switch animation clips
	- Fill out the clip names (as named in project) on Animation Names in the order you want to play them
*/

var animationNames : String[]; //Fill out the names in the Inspector

private var currentAnimation : int = 0; //Keep track of our current animation
private var animationComponent : Animation; //Cache the Animation Component

function Start () {
	animationComponent = GetComponent(Animation);
}

function Update () {
	if (Input.GetButtonDown("Fire1")) {
		playAnimation();
	} 
}

function playAnimation () {
	if(!animation.isPlaying) {
		animation.Play(animationNames[currentAnimation]);
		currentAnimation++;
		if(currentAnimation>=animationComponent.GetClipCount()) {
			currentAnimation=0;
		}
	}
}

Basically just keep track of the current clip number and reference them with a name (as animation.Play only takes a string).