I made a script that is supposed to play an animation when I press the “e” key.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class DrawerInteract : MonoBehaviour
{
public GameObject drawerOpen;
private Animation drawer;
void Awake()
{
drawer = gameObject.GetComponent <Animation> ();
}
void Open()
{
if (Input.GetKeyDown ("e"))
{
drawer.Play();
}
}
The script appears to compile but the animation is not playing when I press the “e” key in-game. What is wrong with the code?