private void Awake()
        {
            m_CinemachineConfiner = FindObjectOfType <Cinemachine.CinemachineConfiner>();
            if (m_CinemachineConfiner != null)
            {
                m_OriginalCameraBound = m_CinemachineConfiner.m_BoundingShape2D;
            }

            m_CinemachineVirtualCamera = cinemachineVirtualCamera;
            if (m_CinemachineVirtualCamera != null)
            {
                m_CinemachineTransform      = m_CinemachineVirtualCamera.transform;
                m_CinemachineComposer       = m_CinemachineVirtualCamera.GetCinemachineComponent <Cinemachine.CinemachineFramingTransposer>();
                m_OriginalCameraFollowPoint = m_CinemachineVirtualCamera.Follow;
                m_OriginalOrthographicSize  = m_CinemachineVirtualCamera.m_Lens.OrthographicSize;
            }

            if (m_CinemachineComposer != null)
            {
                m_OriginalDeadZoneWidth  = m_CinemachineComposer.m_DeadZoneWidth;
                m_OriginalDeadZoneHeight = m_CinemachineComposer.m_DeadZoneHeight;
            }

            m_VirtualTransform        = new GameObject("VirtualTransform").transform;
            m_VirtualTransform.parent = gameObject.transform;

            GetComponent <Collider2D>().isTrigger = true;

            if (cameraBound != null)
            {
                cameraBound.isTrigger = true;
            }
        }
Exemple #2
0
        IEnumerator CameraMoving()
        {
            cameraShake.Shake(1f, 1f);
            Cinemachine.CinemachineVirtualCamera cinemachineVirtualCamera = Camera.main.GetComponentInChildren <Cinemachine.CinemachineVirtualCamera>();
            Vector3 prePos    = cameraFollowObject.transform.position;
            Vector3 cameraPos = Camera.main.transform.position;

            cameraPos.z = prePos.z;
            cameraFollowObject.transform.position = cameraPos;
            cinemachineVirtualCamera.Follow       = cameraFollowObject.transform;


            Cinemachine.CinemachineFramingTransposer body = cinemachineVirtualCamera.GetCinemachineComponent <Cinemachine.CinemachineFramingTransposer>();
            float xDamping = body.m_XDamping;
            float yDamping = body.m_YDamping;
            float DZWidth  = body.m_DeadZoneWidth;
            float DZHeight = body.m_DeadZoneHeight;

            body.m_XDamping      = 0;
            body.m_YDamping      = 0;
            body.m_DeadZoneWidth = body.m_DeadZoneHeight = 0;

            float elapsed = 0f;

            while (true)
            {
                yield return(null);

                elapsed += Time.deltaTime;
                cameraFollowObject.transform.position += (prePos - cameraFollowObject.transform.position).normalized * 2f * Time.deltaTime;
                if (elapsed >= 4f)
                {
                    break;
                }
            }

            cameraFollowObject.transform.position = prePos;
            StartCoroutine("BossUpdate");
        }