Detect Stopped Animation and Play Idle

Hi guys,

I’m sure this has been talked about before however I’m having trouble detecting when an animation called “Play” has stopped. When the animation has come to a halt I want to resume the idle animation called “Eat”.

here is the code I have so far, any help would be great

  using UnityEngine;
using System.Collections;

public class ClickPlay : MonoBehaviour {

 private string getName;
 public Animation anim;
void Start(){


void Update(){
     if (Input.GetMouseButtonDown(0)){ // if left button pressed...
       Ray ray = GetComponent<Camera>().ScreenPointToRay(Input.mousePosition);
       RaycastHit hit;
       GameObject go = null;
       if (Physics.Raycast(ray, out hit)){
        getName =;
        go = hit.collider.gameObject;
             Debug.Log("Mouse Down Hit the following object: " +;

                    //if animation has finished on deer, then
                    /// resume the Eat animation in a loop

                    if (!anim.IsPlaying("Play"))
            print("Animation Done");


I would like to know this too