示例#1
0
    void Awake()
    {
        if (GameObject.FindGameObjectWithTag("VirtualCamera") != null)
        {
            virtCam = GameObject.FindGameObjectWithTag("VirtualCamera").GetComponent <CinemachineVirtualCamera>();
            pov     = virtCam.GetCinemachineComponent <CinemachinePOV>();
        }

        if (lockCursor)
        {
            Cursor.lockState = CursorLockMode.Locked;
            Cursor.visible   = false;
        }


        if (usingKeyboard)
        {
            UsingKeyBoard();
        }

        if (usingController)
        {
            UsingController();
        }
    }
示例#2
0
    public void MakeCameraLookLikeVCam(CinemachineVirtualCamera vcam)
    {
        CinemachinePOV pov = vcam.GetCinemachineComponent <CinemachinePOV>();

        _freeLook.m_XAxis.Value = pov.m_HorizontalAxis.Value;
        _freeLook.m_YAxis.Value = pov.m_VerticalAxis.Value;
    }
示例#3
0
        public void SetupReferences()
        {
            lwrpAsset = GraphicsSettings.renderPipelineAsset as UnityEngine.Rendering.Universal.UniversalRenderPipelineAsset;
            GeneralSettingsController generalSettingsController = GameObject.FindObjectOfType <GeneralSettingsController>();
            QualitySettingsController qualitySettingsController = GameObject.FindObjectOfType <QualitySettingsController>();

            Assert.IsNotNull(generalSettingsController, "GeneralSettingsController not found in scene");
            Assert.IsNotNull(qualitySettingsController, "QualitySettingsController not found in scene");

            freeLookCamera = generalSettingsController.thirdPersonCamera;
            Assert.IsNotNull(freeLookCamera, "GeneralSettingsController: thirdPersonCamera reference missing");

            CinemachineVirtualCamera virtualCamera = generalSettingsController.firstPersonCamera;

            Assert.IsNotNull(virtualCamera, "GeneralSettingsController: firstPersonCamera reference missing");
            povCamera = virtualCamera.GetCinemachineComponent <CinemachinePOV>();
            Assert.IsNotNull(povCamera, "GeneralSettingsController: firstPersonCamera doesn't have CinemachinePOV component");

            environmentLight = qualitySettingsController.environmentLight;
            Assert.IsNotNull(environmentLight, "QualitySettingsController: environmentLight reference missing");

            postProcessVolume = qualitySettingsController.postProcessVolume;
            Assert.IsNotNull(postProcessVolume, "QualitySettingsController: postProcessVolume reference missing");

            firstPersonCamera = qualitySettingsController.firstPersonCamera;
            Assert.IsNotNull(firstPersonCamera, "QualitySettingsController: firstPersonCamera reference missing");
            Assert.IsNotNull(qualitySettingsController.thirdPersonCamera, "QualitySettingsController: thirdPersonCamera reference missing");
        }
示例#4
0
    public static void ResetRotation(this CinemachinePOV self, Quaternion targetRot)
    {
        Vector3   up     = self.VcamState.ReferenceUp;
        Vector3   fwd    = Vector3.forward;
        Transform parent = self.VirtualCamera.transform.parent;

        if (parent != null)
        {
            fwd = parent.rotation * fwd;
        }

        self.m_HorizontalAxis.Value = 0;
        self.m_HorizontalAxis.Reset();
        Vector3 targetFwd = targetRot * Vector3.forward;
        Vector3 a         = fwd.ProjectOntoPlane(up);
        Vector3 b         = targetFwd.ProjectOntoPlane(up);

        if (!a.AlmostZero() && !b.AlmostZero())
        {
            self.m_HorizontalAxis.Value = Vector3.SignedAngle(a, b, up);
        }

        self.m_VerticalAxis.Value = 0;
        self.m_VerticalAxis.Reset();
        fwd = Quaternion.AngleAxis(self.m_HorizontalAxis.Value, up) * fwd;
        Vector3 right = Vector3.Cross(up, fwd);

        if (!right.AlmostZero())
        {
            self.m_VerticalAxis.Value = Vector3.SignedAngle(fwd, targetFwd, right);
        }
    }
示例#5
0
    // Update is called once per frame
    void Update()
    {
        float halfDeadZone = deadZoneSize / 2;
        float axis         = mFreeLook.m_XAxis.Value;

        if (axis > 180)
        {
            axis = Mathf.Max(axis, 180 + halfDeadZone);
        }
        if (axis < 180)
        {
            axis = Mathf.Min(axis, 180 - halfDeadZone);
        }
        mFreeLook.m_XAxis.Value = axis;

        for (int i = 0; i < 3; i++)
        {
            CinemachinePOV pov              = povs[i];
            float          axisLook         = Mathf.Repeat(pov.m_HorizontalAxis.Value, 360);
            float          halfDeadZoneLook = deadZoneSizeLook / 2;
            if (axisLook > 180)
            {
                axisLook = Mathf.Max(axisLook, 180 + halfDeadZoneLook);
            }
            if (axisLook < 180)
            {
                axisLook = Mathf.Min(axisLook, 180 - halfDeadZoneLook);
            }
            pov.m_HorizontalAxis.Value = axisLook;
        }
    }
示例#6
0
    public override void Init(Camera cameraTransform)
    {
        base.Init(cameraTransform);

        if (defaultVirtualCamera is CinemachineVirtualCamera vcamera)
        {
            pov = vcamera.GetCinemachineComponent <CinemachinePOV>();
        }
    }
示例#7
0
 void StartMenu()
 {
     pov = PlayerController.player.getPOV();
     GUI_Pause.SetActive(true);
     Cursor.visible = true;
     AudioManager.manager.PauseAllSounds();
     Time.timeScale = 0f;
     inMenu         = true;
 }
示例#8
0
 private void Awake()
 {
     vBrain  = FindObjectOfType <CinemachineBrain>();
     vCam    = GetComponent <CinemachineVirtualCamera>();
     vCamPOV = vCam.GetCinemachineComponent <CinemachinePOV>();
     if (vCamPOV == null)
     {
         Debug.LogWarning("Virtual Camera Aim Type must be set to 'POV'");
     }
 }
        private void Awake()
        {
            VCam         = GetComponent <CinemachineVirtualCamera>();
            UnityCamera  = Camera.main;
            POVComponent = VCam.GetCinemachineComponent <CinemachinePOV>();

            horizontalAxisName = POVComponent.m_HorizontalAxis.m_InputAxisName;
            verticalAxisName   = POVComponent.m_VerticalAxis.m_InputAxisName;

            // Disable POV Module or we might start partially in the wrong state.
            TogglePOV(false);
        }
示例#10
0
 // Start is called before the first frame update
 void Start()
 {
     virtualCam                = GetComponent <CinemachineVirtualCamera>();
     virtualCamPOV             = virtualCam.GetCinemachineComponent <CinemachinePOV>();
     virtualCamFrameTransposer = virtualCam.GetCinemachineComponent <CinemachineFramingTransposer>();
     virtualCamFrameTransposer.m_CameraDistance = defaultZoom;
     currentZoom = defaultZoom;
     if (virtualCamPOV)
     {
         virtualCamPOV.m_HorizontalAxis.m_MaxSpeed = PlayerPrefs.GetFloat("playerSens");
     }
 }
示例#11
0
    void Start()
    {
        footing = GetComponent <AudioSource>();
        vCamPOV = vCam.GetCinemachineComponent <CinemachinePOV>();

        canMove        = false;
        Cursor.visible = false;
        currentState   = PlayerState.still;
        originalSpeed  = speed;
        standPos       = transform.position.y;
        crouchPos      = standPos - .8f;
    }
示例#12
0
    void Start()
    {
        var vcam = GetComponent <CinemachineVirtualCamera>();

        if (vcam != null)
        {
            POVCam = vcam.GetCinemachineComponent <CinemachinePOV>();
        }
        if (shouldInheritAtStart)
        {
            vcam.m_Transitions.m_InheritPosition = true;
        }
    }
示例#13
0
    void Awake()
    {
        POV = cinemachine.AddCinemachineComponent <CinemachinePOV>();
        POV.m_HorizontalAxis.m_SpeedMode = AxisState.SpeedMode.InputValueGain;
        POV.m_VerticalAxis.m_SpeedMode   = AxisState.SpeedMode.InputValueGain;

#if UNITY_STANDALONE
        Cursor.lockState = CursorLockMode.Locked;
        Cursor.visible   = false;
#elif UNITY_ANDROID
        mobileHud.setActive(true);
        POV.m_HorizontalAxis.m_InputAxisName = "";
        POV.m_VerticalAxis.m_InputAxisName   = "";

        joyPlayer = GameObject.Find("JoystickPlayer").GetComponent <Joystick>();
        joyCamera = GameObject.Find("JoystickCamera").GetComponent <Joystick>();
#endif
    }
示例#14
0
    /// <summary>
    /// 设置摄像头角度
    /// </summary>
    /// <param name="vAxis"></param>
    /// <param name="hAxis"></param>
    public void SetCameraAxis(float vAxis, float hAxis)
    {
        CinemachineVirtualCamera cameraForFirst = manager.cameraForFirst;
        //第一人称
        CinemachinePOV cinemachinePOV = cameraForFirst.GetCinemachineComponent <CinemachinePOV>();

        if (cinemachinePOV != null)
        {
            cinemachinePOV.m_VerticalAxis.Value   = vAxis;
            cinemachinePOV.m_HorizontalAxis.Value = hAxis;
        }

        CinemachineFreeLook cameraForThree = manager.cameraForThree;

        //第三人称
        cameraForThree.m_XAxis.Value = vAxis;
        cameraForThree.m_YAxis.Value = hAxis;
    }
示例#15
0
    /// <summary>
    /// 修改摄像头速度
    /// </summary>
    /// <param name="speed"></param>
    public void ChangeCameraSpeed(float xSpeed, float ySpeed)
    {
        CinemachineVirtualCamera cameraForFirst = manager.cameraForFirst;
        //第一人称
        CinemachinePOV cinemachinePOV = cameraForFirst.GetCinemachineComponent <CinemachinePOV>();

        if (cinemachinePOV != null)
        {
            cinemachinePOV.m_VerticalAxis.m_MaxSpeed   = ySpeed / timeScale;
            cinemachinePOV.m_HorizontalAxis.m_MaxSpeed = xSpeed / timeScale;
        }

        CinemachineFreeLook cameraForThree = manager.cameraForThree;

        //第三人称
        cameraForThree.m_XAxis.m_MaxSpeed = xSpeed / timeScale;
        cameraForThree.m_YAxis.m_MaxSpeed = ySpeed / 100 / timeScale;
    }
        private void SetupReferences()
        {
            urpAsset = GraphicsSettings.renderPipelineAsset as UniversalRenderPipelineAsset;
            Assert.IsNotNull(urpAsset, "urpAsset is null!");

            lwrpaShadowField = urpAsset.GetType().GetField("m_MainLightShadowsSupported", BindingFlags.NonPublic | BindingFlags.Instance);
            Assert.IsNotNull(lwrpaShadowField, "lwrpaShadowField is null!");

            lwrpaShadowResolutionField = urpAsset.GetType().GetField("m_MainLightShadowmapResolution", BindingFlags.NonPublic | BindingFlags.Instance);
            Assert.IsNotNull(lwrpaShadowResolutionField, "lwrpaShadowResolutionField is null!");

            lwrpaSoftShadowField = urpAsset.GetType().GetField("m_SoftShadowsSupported", BindingFlags.NonPublic | BindingFlags.Instance);
            Assert.IsNotNull(lwrpaSoftShadowField, "lwrpaSoftShadowField is null!");

            GeneralSettingsReferences generalSettingsReferences = GameObject.FindObjectOfType <GeneralSettingsReferences>();
            QualitySettingsReferences qualitySettingsReferences = GameObject.FindObjectOfType <QualitySettingsReferences>();

            Assert.IsNotNull(generalSettingsReferences, "GeneralSettingsReferences not found in scene");
            Assert.IsNotNull(qualitySettingsReferences, "QualitySettingsReferences not found in scene");

            freeLookCamera = generalSettingsReferences.thirdPersonCamera;
            Assert.IsNotNull(freeLookCamera, "GeneralSettingsController: thirdPersonCamera reference missing");

            CinemachineVirtualCamera virtualCamera = generalSettingsReferences.firstPersonCamera;

            Assert.IsNotNull(virtualCamera, "GeneralSettingsController: firstPersonCamera reference missing");
            povCamera = virtualCamera.GetCinemachineComponent <CinemachinePOV>();
            Assert.IsNotNull(povCamera, "GeneralSettingsController: firstPersonCamera doesn't have CinemachinePOV component");

            environmentLight = qualitySettingsReferences.environmentLight;
            Assert.IsNotNull(environmentLight, "QualitySettingsController: environmentLight reference missing");

            postProcessVolume = qualitySettingsReferences.postProcessVolume;
            Assert.IsNotNull(postProcessVolume, "QualitySettingsController: postProcessVolume reference missing");

            firstPersonCamera = qualitySettingsReferences.firstPersonCamera;
            Assert.IsNotNull(firstPersonCamera, "QualitySettingsController: firstPersonCamera reference missing");
            Assert.IsNotNull(qualitySettingsReferences.thirdPersonCamera, "QualitySettingsController: thirdPersonCamera reference missing");
        }
 private void Awake()
 {
     _transposer = vCam.GetCinemachineComponent <CinemachinePOV>();
 }
示例#18
0
 private void Awake()
 {
     VCAM.Follow = transform;
     FT          = VCAM.GetCinemachineComponent <CinemachineFramingTransposer>();
     POV         = VCAM.GetCinemachineComponent <CinemachinePOV>();
 }
示例#19
0
 // Use this for initialization
 void Start()
 {
     pov = GetComponent <CinemachineVirtualCamera>().GetCinemachineComponent <CinemachinePOV>();
 }
        public override void Initialize()
        {
            base.Initialize();

            povCamera = GeneralSettingsReferences.i.firstPersonCamera.GetCinemachineComponent <CinemachinePOV>();
        }
示例#21
0
 void Start()
 {
     m_信息 = m_虚拟镜头.GetCinemachineComponent <CinemachinePOV>();
 }
 void Start()
 {
     _post = Camera.main.GetComponent <PostProcessLayer>();
     _info = FindObjectOfType <InfoBehaviour>();
     _pov  = virtualCamera.GetCinemachineComponent <CinemachinePOV>();
 }
示例#23
0
 private void Start()
 {
     current = CannonType.Normal;
     pov     = cm.GetCinemachineComponent <CinemachinePOV>();
 }
示例#24
0
 void Awake()
 {
     povCamera = firstPersonCamera.GetCinemachineComponent <CinemachinePOV>();
     ApplyGeneralSettings(Settings.i.generalSettings);
 }