IEnumerator TrackToPosition(Vector2 position, bool unlock = false, PostLockDelegate postLock = null) { float elapsedTime = 0.0f; Vector3 startPos = transform.position; Vector3 endPos = new Vector3(position.x, position.y, startPos.z); while (elapsedTime < trackingDuration) { yield return(null); elapsedTime += Time.deltaTime; transform.position = Vector3.Lerp(startPos, endPos, elapsedTime / trackingDuration); } if (unlock) { locked = false; } if (postLock != null) { postLock(); } }
public void UnlockCamera(PostLockDelegate postLock = null) { StartCoroutine(TrackToPosition(DefaultPosition(), true, postLock)); }
public void LockCamera(Vector2 position, PostLockDelegate postLock = null) { locked = true; StartCoroutine(TrackToPosition(position, false, postLock)); }