using System.Collections; using System.Collections.Generic; using UnityEngine; public class KeyDoorController : MonoBehaviour { public bool opened = false; public Vector2 doorClosedPosition; // Use this for initialization void Start () { doorClosedPosition = this.transform.position; } // Update is called once per frame void Update () { if (opened) { OpenDoor1(); } } public void OpenDoor1() { this.transform.position = new Vector2(this.transform.position.x, Mathf.Lerp(this.transform.position.y, (doorClosedPosition.y - 1), 2 * Time.deltaTime)); } }