Exemplo n.º 1
0
    /// <summary>
    /// Rotate the camera towards the destination rotation, slowing down while reaching it.
    /// </summary>
    /// <returns></returns>
    private IEnumerator NormalLerpRotating(CameraTarget target, TargetParameters.StaticTargetRotationParameters parameters)
    {
        while (Quaternion.Angle(transform.rotation, target.transform.rotation) > parameters.LerpThreshold)
        {
            transform.rotation = Quaternion.Slerp(transform.rotation, target.transform.rotation, parameters.LerpSpeed * Time.deltaTime);
            yield return(null);
        }

        CameraEventSystem.CameraTargetRotationReached(target, parameters);
    }
Exemplo n.º 2
0
    /// <summary>
    /// Rotate the camera towards the destination rotation at constant speed, reaching in the given time.
    /// </summary>
    /// <returns></returns>
    private IEnumerator ConstantLerpRotating(CameraTarget target, TargetParameters.StaticTargetRotationParameters parameters)
    {
        float      elapsedRotatingLerpTime = 0;
        Quaternion startingRotation        = transform.rotation;
        float      step;

        while (elapsedRotatingLerpTime < parameters.Duration)
        {
            step = elapsedRotatingLerpTime / parameters.Duration;
            elapsedRotatingLerpTime += Time.deltaTime;
            transform.rotation       = Quaternion.Slerp(startingRotation, target.transform.rotation, step);
            yield return(null);
        }

        CameraEventSystem.CameraTargetRotationReached(target, parameters);
    }
Exemplo n.º 3
0
 /// <summary>
 /// Immediately rotate the camera to match the target rotation.
 /// </summary>
 private void ImmediateRotating(CameraTarget target, TargetParameters.StaticTargetRotationParameters parameters)
 {
     transform.rotation = target.transform.rotation;
     CameraEventSystem.CameraTargetRotationReached(target, parameters);
 }