using System.Collections; using System.Collections.Generic; using UnityEngine; public class twween : MonoBehaviour { private float _time; private bool isTrigger; private bool isOpen; // Use this for initialization void Start () { isOpen = false; isTrigger = false; } // Update is called once per frame void Update () { if (Input.GetKeyDown (KeyCode.F)) { isTrigger = true; } } void FixedUpdate() { ControlDoor (); } void ControlDoor() { if (isTrigger == true) { if (isOpen == false) { transform.localEulerAngles = new Vector3 (0, Mathf.LerpAngle (transform.localEulerAngles.y, 90f, 0.05f), 0); } else { transform.localEulerAngles = new Vector3 (0, Mathf.LerpAngle (transform.localEulerAngles.y, 0f, 0.05f), 0); } } if (transform.localEulerAngles.y>=85f) { isTrigger = false; isOpen = true; } if (transform.localEulerAngles.y<=0.1f) { isTrigger = false; isOpen = false; } } }