How to use this script:
/* How to use this script:1. Drag the script to the trigger/s object/s (a button, a lever, etc) An elevator will have at least two triggers (one in the bottom floor and one in the top floor)2. In the trigger object/s inspector:a) Drag the elevator object to the Transform fieldb. Type in the max top position and bottom position that the elevator will move */using UnityEngine;using System.Collections;public class Elevator : MonoBehaviour { public Transform elevator; public float topPosition, bottomPosition; private bool isUp; void OnTriggerStay(Collider other) { if (other.gameObject.CompareTag("Player") && (!isUp) && Input.GetKey(KeyCode.E)) { StartCoroutine("LiftingUp"); } else if (other.gameObject.CompareTag("Player") && (isUp) && Input.GetKey(KeyCode.E)) { StartCoroutine("LiftingDown"); } } IEnumerator LiftingUp() { while (elevator.position.y < topPosition) { elevator.Translate(Vector3.up * .3f * Time.deltaTime); yield return null; } isUp = true; } IEnumerator LiftingDown() { while (elevator.position.y > bottomPosition) { elevator.Translate(Vector3.down * .3f * Time.deltaTime); yield return null; } isUp = false; }}