Esempio n. 1
0
    private void SetCameraDynamicTargetPosition(GameObject target, TargetParameters.DynamicTargetPositionParameters parameters)
    {
        if (positionCoroutine != null)
        {
            StopCoroutine(positionCoroutine);
        }

        switch (parameters.CameraExecutionMode)
        {
        case CameraExecutionMode.Immediate:
            //ImmediatePositioning(position, parameters);
            break;

        case CameraExecutionMode.ConstantLerp:
            //StartCoroutine(ConstantLerpPositioning(position, parameters));
            break;

        case CameraExecutionMode.NormalLerp:
            positionCoroutine = StartCoroutine(FollowPosition(target, parameters));
            break;

        case CameraExecutionMode.SmoothLerp:
            //StartCoroutine(SmoothLerpPositioning(position, parameters));
            break;

        case CameraExecutionMode.CustomLerp:
            positionCoroutine = StartCoroutine(customDynamicPositioningLerp(target, parameters));
            break;
        }
    }
Esempio n. 2
0
    /// <summary>
    /// Follow the dynamic target position.
    /// </summary>
    /// <param name="target"></param>
    /// <param name="parameters"></param>
    /// <returns></returns>
    private IEnumerator FollowPosition(GameObject target, TargetParameters.DynamicTargetPositionParameters parameters)
    {
        Vector3 destination;

        while (true)
        {
            destination = target.transform.position + parameters.AdditiveOffset;
            if (Vector3.Distance(transform.position, destination) > parameters.LerpThreshold)
            {
                Moving             = true;
                transform.position = Vector3.Lerp(transform.position, destination, parameters.LerpSpeed * Time.deltaTime);
            }
            else
            {
                Moving = false;
            }

            yield return(null);
        }
    }
    private void Update()
    {
        if (Input.GetKeyDown(KeyCode.Space))
        {
            if (TreatTargetAs == TargetType.Static) //STATIC TARGET
            {
                TargetParameters.StaticTargetRotationParameters rotParams = TargetParameters.GetDefaultStaticRotationParameters();
                rotParams.Duration = 8f;
                cameraTest.SetStaticCameraTarget(Target, rotParams);

                TargetParameters.StaticTargetPositionParameters posParams = TargetParameters.GetDefaultStaticPositionParameters();
                posParams.CameraExecutionMode = CameraExecutionMode.CustomLerp;
                posParams.StartSCParameters.SinIntensityChangeTimer = 2f;
                posParams.StartSCParameters.CosIntensityChangeTimer = 2f;
                posParams.StartSCParameters.MinCosIntensity         = 0.1f;
                posParams.StartSCParameters.MaxCosIntensity         = 0.12f;
                posParams.StartSCParameters.MinSinIntensity         = 0.1f;
                posParams.StartSCParameters.MaxSinIntensity         = 0.11f;

                posParams.SteadyCamOnStart = SteadyCamBehaviour.TurnOnAndOverride;
                posParams.SteadyCamOnEnd   = SteadyCamBehaviour.TurnOnAndOverride;

                cameraTest.SetStaticCameraTarget(Target, posParams);
            }
            else //DYNAMIC TARGET
            {
                TargetParameters.DynamicTargetPositionParameters dynamicPosParams = TargetParameters.GetDefaultDynamicPositionParameters();
                dynamicPosParams.LerpSpeed = 2f;
                cameraTest.SetDynamicCameraTarget(Target.transform.GetChild(0).GetComponent <CameraTarget>(), dynamicPosParams);

                TargetParameters.DynamicTargetRotationParameters dynamicRotParams = TargetParameters.GetDefaultDynamicRotationParameters();
                dynamicRotParams.DynamicRotationBehaviour = DynamicRotationBehaviour.LookAt;
                dynamicRotParams.LerpSpeed = 5f;
                cameraTest.SetDynamicCameraTarget(Target, dynamicRotParams);
            }
        }
        //else if (Input.GetKey(KeyCode.LeftControl))
        //{
        //    NextTarget();
        //}
    }
Esempio n. 4
0
 public static void SetCameraDynamicTargetPosition(GameObject target, TargetParameters.DynamicTargetPositionParameters parameters)
 {
     SetCameraDynamicTargetPositionEvent.Invoke(target, parameters);
 }
Esempio n. 5
0
 public void SetDynamicCameraTarget(CameraTarget cameraTarget, TargetParameters.DynamicTargetPositionParameters posParameters, TargetParameters.DynamicTargetRotationParameters rotParameters)
 {
     CameraEventSystem.SetCameraDynamicTargetPosition(cameraTarget.gameObject, posParameters);
     CameraEventSystem.SetCameraDynamicTargetRotation(cameraTarget.gameObject, rotParameters);
 }