Example #1
0
 public virtual void Set_State(FreeLookCameraState profile)
 {
     Pivot.localPosition         = profile.PivotPos;
     Cam.transform.localPosition = profile.CamPos;
     Cam.fieldOfView             = ActiveFOV = profile.CamFOV;
     OnStateChange.Invoke();
 }
Example #2
0
        internal void SetState(FreeLookCameraState state, bool temporal)
        {
            if (state == null)
            {
                return;
            }

            NextState = state;

            if (currentState && NextState == currentState)
            {
                return;
            }

            if (IChangeStates != null)
            {
                StopCoroutine(IChangeStates);
            }

            if (!temporal)
            {
                DefaultState = state;            //Changes wth this
            }
            IChangeStates = StateTransition(state.transition);
            StartCoroutine(IChangeStates);
        }
Example #3
0
 private void SetState(FreeLookCameraState state, bool temporal)
 {
     if (state == null)
     {
         return;
     }
     if (mCamera == null)
     {
         return;
     }
     mCamera.SetState(state, temporal);
 }
Example #4
0
        private void UpdateState(FreeLookCameraState state)
        {
            if (state == null)
            {
                return;
            }

            Pivot.localPosition = state.PivotPos;
            CamT.localPosition  = state.CamPos;
            Cam.fieldOfView     = ActiveFOV = state.CamFOV;
            OnStateChange.Invoke();
        }
Example #5
0
        public void SetCamera(MFreeLookCamera Freecamera)
        {
            mCamera = Freecamera;
            if (mCamera)
            {
                cam = mCamera.Cam.GetComponent <Camera>();
            }
            ChangeStates = StateTransition(transition);

            currentState  = null;
            NextState     = null;
            Mounted       = null;
            MountedTarget = null;
        }
Example #6
0
        protected void Awake()
        {
            Cam   = GetComponentInChildren <Camera>();
            CamT  = GetComponentInChildren <Camera>().transform;
            Pivot = Cam.transform.parent;

            currentState = null;
            NextState    = null;

            if (manager)
            {
                manager.SetCamera(this);
            }

            if (DefaultState)
            {
                Set_State(DefaultState);
            }

            Cursor.lockState = m_LockCursor ? CursorLockMode.Locked : CursorLockMode.None;  // Lock or unlock the cursor.
            Cursor.visible   = !m_LockCursor;

            m_PivotEulers        = Pivot.rotation.eulerAngles;
            m_PivotTargetRot     = Pivot.transform.localRotation;
            m_TransformTargetRot = transform.localRotation;


            ActiveFOV = Cam.fieldOfView;

            inputSystem = DefaultInput.GetInputSystem(PlayerID);

            Horizontal.InputSystem = Vertical.InputSystem = inputSystem;        //Update the Input System on the Axis
            defaultUpdate          = updateType;

            if (DefaultState == null)
            {
                // FreeLookCameraState defaault = ScriptableObject.CreateInstance< new FreeLookCameraState(Cam.fieldOfView, Pivot.localPosition, CamT.localPosition);

                DefaultState = ScriptableObject.CreateInstance <FreeLookCameraState>();

                DefaultState.CamFOV   = Cam.fieldOfView;
                DefaultState.PivotPos = Pivot.localPosition;
                DefaultState.CamPos   = CamT.localPosition;


                DefaultState.name = "Default State";

                OnStateChange.Invoke();
            }
        }
Example #7
0
        void UpdateState(FreeLookCameraState state)
        {
            if (mCamera == null)
            {
                return;
            }
            if (state == null)
            {
                return;
            }

            mCamera.Pivot.localPosition = state.PivotPos;
            mCamera.Cam.localPosition   = state.CamPos;
            mCamera.Cam.GetComponent <Camera>().fieldOfView = state.CamFOV;
        }
Example #8
0
        IEnumerator StateTransition(float time)
        {
            inTransition = true;
            float elapsedTime = 0;

            currentState = NextState;
            while (elapsedTime < time)
            {
                mCamera.Pivot.localPosition = Vector3.Lerp(mCamera.Pivot.localPosition, NextState.PivotPos, Mathf.SmoothStep(0, 1, elapsedTime / time));
                mCamera.Cam.localPosition   = Vector3.Lerp(mCamera.Cam.localPosition, NextState.CamPos, Mathf.SmoothStep(0, 1, elapsedTime / time));
                mCamera.Cam.GetComponent <Camera>().fieldOfView = Mathf.Lerp(mCamera.Cam.GetComponent <Camera>().fieldOfView, NextState.CamFOV, Mathf.SmoothStep(0, 1, elapsedTime / time));
                elapsedTime += Time.deltaTime;
                yield return(null);
            }
            UpdateState(NextState);
            inTransition = false;
        }
Example #9
0
        private IEnumerator StateTransition(float time)
        {
            float elapsedTime = 0;

            currentState = NextState;

            while (elapsedTime < time)
            {
                Pivot.localPosition = Vector3.Lerp(Pivot.localPosition, NextState.PivotPos, Mathf.SmoothStep(0, 1, elapsedTime / time));
                CamT.localPosition  = Vector3.Lerp(CamT.localPosition, NextState.CamPos, Mathf.SmoothStep(0, 1, elapsedTime / time));
                Cam.fieldOfView     = ActiveFOV = Mathf.Lerp(Cam.fieldOfView, NextState.CamFOV, Mathf.SmoothStep(0, 1, elapsedTime / time));
                OnStateChange.Invoke();
                elapsedTime += Time.deltaTime;
                yield return(null);
            }

            UpdateState(NextState);

            NextState = null;
            yield return(null);
        }
Example #10
0
        public void SetCameraState(FreeLookCameraState state)
        {
            if (mCamera == null)
            {
                return;
            }
            if (state == null)
            {
                return;
            }

            NextState = state;

            if (currentState && NextState == currentState)
            {
                return;
            }

            mCamera.StopCoroutine(ChangeStates);
            ChangeStates = StateTransition(transition);
            mCamera.StartCoroutine(ChangeStates);
        }
Example #11
0
        public void SetCameraState(FreeLookCameraState state)
        {
            if (mCamera == null)
            {
                return;
            }
            if (state == null)
            {
                return;
            }

            NextState = state;


            if (currentState && NextState.Name == currentState.Name)
            {
                return;
            }

            StopAllCoroutines();

            StartCoroutine(StateTransition(transition));
        }
Example #12
0
 public void SetAimRight(FreeLookCameraState state) => AimRight = state;
Example #13
0
 public void SetAimLeft(FreeLookCameraState state) => AimLeft = state;
Example #14
0
 public void Set_State_Smooth(FreeLookCameraState state)
 {
     SetState(state, false);
 }
 public virtual void SetState(FreeLookCameraState profile)
 {
     Pivot.localPosition = profile.PivotPos;
     Cam.localPosition   = profile.CamPos;
     Cam.GetComponent <Camera>().fieldOfView = profile.CamFOV;
 }
Example #16
0
 public void Set_State_Temporal(FreeLookCameraState state)
 {
     SetState(state, true);
 }
Example #17
0
 public virtual void SetTemporalState(FreeLookCameraState state) => SetState(state, true);
Example #18
0
 public virtual void SetState(FreeLookCameraState state) => SetState(state, false);
Example #19
0
 public virtual void SetStateInstant(FreeLookCameraState state)
 {
     mCamera.SetState_Instant(state, false);
 }
Example #20
0
 void Start()
 {
     currentState = Default;
     UpdateState(currentState);
 }
Example #21
0
 private void SetState(FreeLookCameraState state, bool temporal) => mCamera?.SetState(state, temporal);
Example #22
0
 public void SetMounted(FreeLookCameraState state)
 {
     Mounted = state;
     SetCameraState(Mounted);
 }