Exemple #1
0
    //カメラの回転 マウス
    private void CameraRotation2MouseControl()
    {
        if (Input.GetMouseButtonDown(0))
        {
            startMousePos         = Input.mousePosition;
            _presentCamRotation.x = camTransform.transform.eulerAngles.x;
            _presentCamRotation.y = camTransform.transform.eulerAngles.y;
        }

        if (Input.GetMouseButton(0))
        {
            //(移動開始座標 - マウスの現在座標) / 解像度 で正規化
            float x       = (startMousePos.x - Input.mousePosition.x) / Screen.width;
            float y       = (startMousePos.y - Input.mousePosition.y) / Screen.height;
            var   headpos = barracudaRunner.GetHeadPosition();
            camTransform.RotateAround(headpos, Vector3.up, -x * 10);
            camTransform.RotateAround(headpos, camTransform.right, y * 10);
        }
    }
Exemple #2
0
    void Update()
    {
        if (!CameraMoveActive)
        {
            return;
        }

        if (Input.GetMouseButtonDown(0))
        {
            CameraAngleCnt++;
            var headpos = barracudaRunner.GetHeadPosition();

            // マウスホイールの回転値を変数 scroll に渡す
            scroll = Input.GetAxis("Mouse ScrollWheel");

            if (CameraAngleCnt == 1)
            {
                mainCamera.fieldOfView = 60;
                camTransform.position  = new Vector3(headpos.x - 0.5f, headpos.y, headpos.z - 0.5f);
                this.transform.LookAt(headpos);
            }
            else if (CameraAngleCnt == 2)
            {
                mainCamera.fieldOfView = 60;
                camTransform.position  = new Vector3(headpos.x + 0.5f, headpos.y, headpos.z - 0.5f);
                this.transform.LookAt(headpos);
            }
            else if (CameraAngleCnt == 3)
            {
                mainCamera.fieldOfView = 60;
                camTransform.position  = new Vector3(headpos.x, headpos.y, headpos.z - 0.8f);
                this.transform.LookAt(headpos);
            }
            else if (CameraAngleCnt == 4)
            {
                mainCamera.fieldOfView = 60;
                CameraAngleCnt         = 0;
                camTransform.position  = initialCamposition;
            }
        }
        else if (Input.GetMouseButtonDown(1))
        {
            uiScript.NextAvatar();
            var headpos = barracudaRunner.GetHeadPosition();
            if (CameraAngleCnt == 1)
            {
                mainCamera.fieldOfView = 60;
                camTransform.position  = new Vector3(headpos.x - 0.5f, headpos.y, headpos.z - 0.5f);
                this.transform.LookAt(headpos);
            }
            else if (CameraAngleCnt == 2)
            {
                mainCamera.fieldOfView = 60;
                camTransform.position  = new Vector3(headpos.x + 0.5f, headpos.y, headpos.z - 0.5f);
                this.transform.LookAt(headpos);
            }
            else if (CameraAngleCnt == 3)
            {
                mainCamera.fieldOfView = 60;
                camTransform.position  = new Vector3(headpos.x, headpos.y, headpos.z - 0.8f);
                this.transform.LookAt(headpos);
            }
            else if (CameraAngleCnt == 4)
            {
                mainCamera.fieldOfView = 60;
                CameraAngleCnt         = 0;
                camTransform.position  = initialCamposition;
            }
        }

        // マウスホイールの回転値を変数 scroll に渡す
        scroll = Input.GetAxis("Mouse ScrollWheel") * 50;
        mainCamera.fieldOfView += scroll;

        /*
         * if (CameraAngleCnt == 1)
         * {
         *  camera.fieldOfView += scroll;
         * }
         * else if (CameraAngleCnt == 2)
         * {
         *  camera.fieldOfView += scroll;
         * }
         * else if (CameraAngleCnt == 3)
         * {
         *  camera.fieldOfView += scroll;
         * }
         * else if (CameraAngleCnt == 4)
         * {
         *  camera.fieldOfView += scroll;
         * }
         */
        /**/
        CamControlIsActive(); //カメラ操作の有効無効

        if (CameraMoveActive)
        {
            ResetCameraRotation();        //回転角度のみリセット
            CameraRotationMouseControl(); //カメラの回転 マウス
            CameraSlideMouseControl();    //カメラの縦横移動 マウス
            CameraPositionKeyControl();   //カメラのローカル移動 キー
        }
        /**/
    }