コード例 #1
0
    private void HandlePlayerInput()
    {
        var deadZone = 0.01f;

        // If right mouse button is down, get mouse axis input.
        if (Input.GetMouseButton(1))
        {
            _thirdPersonCamera.MouseX += Input.GetAxis("Mouse X") * MouseXSensitivity;
            _thirdPersonCamera.MouseY -= Input.GetAxis("Mouse Y") * MouseYSensitivity;
        }

        // Clamp (limit) mouse Y rotation. Uses thirdPersonCameraHelper.cs.
        _thirdPersonCamera.MouseY = ThirdPerson_Helper.clampingAngle(_thirdPersonCamera.MouseY,
                                                                     _thirdPersonCamera.YMinLimit,
                                                                     _thirdPersonCamera.YMaxLimit
                                                                     );

        // Clamp (limit) mouse scroll wheel.
        if (Input.GetAxis("Mouse ScrollWheel") > deadZone || Input.GetAxis("Mouse ScrollWheel") < -deadZone)
        {
            _thirdPersonCamera.DesiredDistance = Mathf.Clamp(_thirdPersonCamera.Distance -
                                                             Input.GetAxis("Mouse ScrollWheel") *
                                                             MouseWheelSensitivity,
                                                             _thirdPersonCamera.DistanceMin,
                                                             _thirdPersonCamera.DistanceMax
                                                             );
            _thirdPersonCamera.PreOccludedDistance  = _thirdPersonCamera.DesiredDistance;
            _thirdPersonCamera.DistanceCameraSmooth = _thirdPersonCamera.DistanceSmooth;
        }
    }
コード例 #2
0
    private void HandlePlayerInput()
    {
        float deadZone = 0.01f;

        // If right mouse button is down, get mouse axis input.
        if (Input.GetMouseButton(1))
        {
            thirdPersonCamera.mouseX += Input.GetAxis("Mouse X") * mouseXSensitivity;
            thirdPersonCamera.mouseY -= Input.GetAxis("Mouse Y") * mouseYSensitivity;
        }

        // Clamp (limit) mouse Y rotation. Uses thirdPersonCameraHelper.cs.
        thirdPersonCamera.mouseY = ThirdPerson_Helper.clampingAngle(thirdPersonCamera.mouseY,
                                                                    thirdPersonCamera.yMinLimit,
                                                                    thirdPersonCamera.yMaxLimit
                                                                    );

        // Clamp (limit) mouse scroll wheel.
        if (Input.GetAxis("Mouse ScrollWheel") > deadZone || Input.GetAxis("Mouse ScrollWheel") < -deadZone)
        {
            thirdPersonCamera.desiredDistance = Mathf.Clamp(thirdPersonCamera.distance -
                                                            Input.GetAxis("Mouse ScrollWheel") *
                                                            mouseWheelSensitivity,
                                                            thirdPersonCamera.distanceMin,
                                                            thirdPersonCamera.distanceMax
                                                            );
            thirdPersonCamera.preOccludedDistance  = thirdPersonCamera.desiredDistance;
            thirdPersonCamera.distanceCameraSmooth = thirdPersonCamera.distanceSmooth;
        }
    }