Im trying to have a character from the First person POV walk up to a door, press “E” and have it play an animation to open that door. Then press “F” and play a closing animation. I’ve created this animation in Unity, can someone help me? Sorry if this is a stupid question, but I can’t seem to fix it. Here is my code:
using UnityEngine;
using System.Collections;
public class DoorOpenClose : MonoBehaviour {
// Use this for initialization
void Start() {
//open door when pressing "e" and close door when "f" is pressed
//Door open animation titled "UnityDoor"
//Door close animation titled “UnityDoorClose”
}
// Update is called once per frame
void Update() {
{
if (Input.GetKeyDown("E"))
animation.Play("UnityDoor");
}
}