///----------------------------------------------------------------------------------------------
#if CINEMACHINE_ASSET_STORE //Deprecated version of cinemachine
        public override void UpdateCameraState(Vector3 worldUp, float deltaTime)
        {
            if (!Camera2)
            {
                return;
            }
            if (!Camera1)
            {
                return;
            }
            _state    = Camera2.State;
            _state    = CameraState.Lerp(_state, Camera1.State, 1 - Weight);
            LiveChild = Weight > .5f ? Camera2 : Camera1;
        }
示例#2
0
        /// <summary>Called by CinemachineCore at designated update time
        /// so the vcam can position itself and track its targets.  This implementation
        /// computes and caches the weighted blend of the tracked cameras.</summary>
        /// <param name="worldUp">Default world Up, set by the CinemachineBrain</param>
        /// <param name="deltaTime">Delta time for time-based effects (ignore if less than 0)</param>
        public override void UpdateCameraState(Vector3 worldUp, float deltaTime)
        {
            //UnityEngine.Profiling.Profiler.BeginSample("CinemachineMixingCamera.UpdateCameraState");
            CinemachineVirtualCameraBase[] children = ChildCameras;
            LiveChild = null;
            float highestWeight = 0;
            float totalWeight   = 0;

            for (int i = 0; i < MaxCameras && i < children.Length; ++i)
            {
                CinemachineVirtualCameraBase vcam = children[i];
                if (vcam.isActiveAndEnabled)
                {
                    float weight = Mathf.Max(0, GetWeight(i));
                    if (weight > UnityVectorExtensions.Epsilon)
                    {
                        totalWeight += weight;
                        if (totalWeight == weight)
                        {
                            m_State = vcam.State;
                        }
                        else
                        {
                            m_State = CameraState.Lerp(m_State, vcam.State, weight / totalWeight);
                        }

                        if (weight > highestWeight)
                        {
                            highestWeight = weight;
                            LiveChild     = vcam;
                        }
                    }
                }
            }
            //UnityEngine.Profiling.Profiler.EndSample();
        }
示例#3
0
    private IEnumerator StateTransitionCoroutine()
    {
        _transitioning = true;
        float timer = Time.deltaTime;

        Vector3 tmp = _lookAtPosition;

        while (timer < _newState.transitionTime)
        {
            float t = timer / _newState.transitionTime;

            state            = CameraState.Lerp(ref _oldState, ref _newState, t);
            _lookAtPosition  = Vector3.Lerp(tmp, _newState.target.TransformPoint(_newState.lookOffset), t);
            _cam.fieldOfView = state.fieldOfView;

            yield return(null);

            timer += Time.deltaTime;
        }

        state            = _newState;
        _cam.fieldOfView = state.fieldOfView;
        _transitioning   = false;
    }