I'm trying to animate a chest opening and closing, but the opening and closing animations aren't playing when they should.

I have a script attached to a chest that’s meant to play an opening and closing animations when the chest is clicked and the player is in range. The debug logs show that the script is able to detect the collisions and the chest is able to tell when it’s clicked on, but the animations don’t play. I’ve both animations in the animator controller, and I’ve got the controller attached to the chest. No errors show up when I run the code.

using UnityEngine;
using System.Collections;

public class Chest : MonoBehaviour {

    public enum ChestState
    {

        open,
        closed,
        inbetween
    }

    public ChestState state;

    private bool touchingChest;

    public GameObject entireChest;
    private Animator chestAnimator;

	// Use this for initialization
	void Start () {

        state = Chest.ChestState.closed;
        touchingChest = false;

        chestAnimator = entireChest.GetComponent<Animator>();
	}

    public void OnTriggerEnter()
    {

        Debug.Log("Colliding");
        touchingChest = true;
    }

    public void OnMouseUp()
    {

        Debug.Log("Space");

        chestAnimator.Play("Open", -1, 0f);

        if (touchingChest == true)
        {

            if (state == ChestState.closed)
                Open();

            else
                Close();

        }
    }

    public void OnTriggerExit ()
    {

        Debug.Log("Exit");
        touchingChest = false;
    }

    private void Open()
    {
        chestAnimator.Play("Open", -1, 0f);
        state = ChestState.open;
    }

    private void Close ()
    {
        chestAnimator.Play("Close", -1, 0f);
        state = ChestState.closed;
    }
}

How do I get the opening and closing animations to play?

I solved the problem. I set a parameter in the animator, made transitions between the open and closed states of the chest with conditions reliant upon that parameter, and then changed my code to reference the parameter rather than the actual clip.