This question was
closed Mar 03, 2017 at 02:44 PM by
PresidentPorpoise for the following reason:
Other
Question by
PresidentPorpoise · Nov 25, 2016 at 08:04 PM ·
animationscripting problemanimatorscripting beginner
Cannot get an animation to play upon key press
Hello, I am a novice when it comes to scripting with Unity. I am trying to get an animation to play when I press down the "e" key. The script compiles but the animation does not play.
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();
}
}
Comment