/// <summary> /// Move the camera towards the destination, slowing down while approaching. /// </summary> /// <returns></returns> private IEnumerator NormalLerpPositioning(CameraTarget target, TargetParameters.StaticTargetPositionParameters parameters) { while (Vector3.Distance(transform.position, target.transform.position) > parameters.LerpThreshold) { transform.position = Vector3.Lerp(transform.position, target.transform.position, parameters.LerpSpeed * Time.deltaTime); yield return(null); } CameraEventSystem.CameraTargetPositionReached(target, parameters); }
/// <summary> /// Move the camera towards the destination at constant speed, reaching in the given time. /// </summary> /// <returns></returns> private IEnumerator ConstantLerpPositioning(CameraTarget target, TargetParameters.StaticTargetPositionParameters parameters) { float elapsedPositioningLerpTime = 0; Vector3 startingPosition = transform.position; float step; while (elapsedPositioningLerpTime < parameters.Duration) { step = elapsedPositioningLerpTime / parameters.Duration; elapsedPositioningLerpTime += Time.deltaTime; transform.position = Vector3.Lerp(startingPosition, target.transform.position, step); yield return(null); } CameraEventSystem.CameraTargetPositionReached(target, parameters); }
/// <summary> /// Immediately move the camera to match the target position. /// </summary> private void ImmediatePositioning(CameraTarget target, TargetParameters.StaticTargetPositionParameters parameters) { transform.position = target.transform.position; CameraEventSystem.CameraTargetPositionReached(target, parameters); }