void UpdateState(MCamState state)
 {
     if (mCamera == null)
     {
         return;
     }
     mCamera.Pivot.localPosition = state.PivotPos;
     mCamera.Cam.localPosition   = state.CamPos;
     mCamera.Cam.GetComponent <Camera>().fieldOfView = state.Cam_FOV;
 }
示例#2
0
        public void SetCameraState(string name)
        {
            NextState = FindState(name);

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

            StopAllCoroutines();
            StartCoroutine(StateTransition(transition));
        }
        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.Cam_FOV, Mathf.SmoothStep(0, 1, elapsedTime / time));
                elapsedTime += Time.deltaTime;
                yield return(null);
            }
            UpdateState(NextState);
            inTransition = false;
        }
 void Start()
 {
     currentState = States.StateCameraList[0]; //Set to the First State
     inTransition = false;
 }
示例#5
0
 // Use this for initialization
 void Start()
 {
     currentState = FindState("Default");
     inTransition = false;
 }