how to declare a animation var

Is it possible to declare an animation variable as follows? var gun_animation : animation

i would like to be able to declare it and be able to call it in a following function. Thanks!

var gun_animation : AnimationClip;

There you go!

Are you talking about Animation component or an AnimationClip?

To declare an Animation component you can use:

var animationComp : Animation;

// test use
animationComp.Play("walk");

If you already have an animation component instance and want to declare an AnimationClip then you can use:

var walkAnimation : AnimationClip;

// test use
animationComp.Play(walkAnimaton.name);

Why do all that work when you could just use a string?

#pragma strict

var animationName : String = "";
var delayTime : float = 1;

function Update () {

	Animate();
}

function Animate () {

	yield WaitForSeconds(delayTime);
	animation.Play("" + animationName);
}