Open Door on Keypress Not Working - Animations

I have added the animations and done all the code but the door will not open. Please could you have a look at the code and see what is happening? C# please :slight_smile:

using UnityEngine;
using System.Collections;

public class DoorControl : MonoBehaviour {

	private Animation _anim;
	public bool doorOpen;

	
	void Start()
	{
			

	}
	
	
	void Update ()

	{

	if(Input.GetKeyDown(KeyCode.Q))
		{
		OpenDoor();
		}

	}

	void OpenDoor()
	{
		if (doorOpen == true) {
			_anim.Play ("ClosingAnimation");
			doorOpen = false;
		}
			else
			{
				_anim.Play("OpenAnimation");
				doorOpen = true;
			}
		}		
	}

Insert to Start method:

_anim = gameObject.GetComponent<Animation>();

but you can play it without _anim variable:

gameObject.animation.Play("AnimName");