How can i make my monster to switch walk animation to death animation on mouse click?

public class ClickDestroy : MonoBehaviour {

public AnimationClip walkClip;
public Animation anim;

the one below for some reason does not work, i think i need to get component Animator and replace it with death animator not replace the animation, i am not sure how to. I also need the dead monster to self destruct after 3 seconds.

void OnMouseDown ()
{
	 
	//anim = GetComponent<Animation>();
	//anim.AddClip(walkClip, "walk");
	//Destroy (gameObject);
}

}

It seems you’re lacking the basic understanding of how the Mecanim animators work in Unity.

The Animator is not just one single animation, it’s a state machine, with many states and each state it’s own animation. Then you define rules for switching between the animations, such as triggers or boolean parameters. Then from the code you can trigger these transitions.

So in your case you would have at least two states, one for walk and one for die, and a transition between walk and die with a “die” trigger parameter. Then from your code, simply set that trigger to true, and the mecanim will switch state and thus switch animation.

Watch this mecanim tutorial to see how it is done: https://unity3d.com/learn/tutorials/modules/beginner/live-training-archive/animate-anything