protected IEnumerator MoveToPosition(Vector3 toPosition, float inTime, bool destroy) { var fromPosition = transform.localPosition; for (var t = 0f; t < 1; t += Time.deltaTime / inTime) { transform.localPosition = Vector3.Lerp(fromPosition, toPosition, t); yield return(null); } elevator.Unlock(); timeAlive = 0.0f; if (destroy) { Destroy(this.gameObject); } }
IEnumerator UnlockAfterTime(float seconds) { yield return(new WaitForSeconds(seconds)); elevator.Unlock(); }