Пример #1
0
 // Use this for initialization
 void Start()
 {
     Joystick      = GameObject.Find("MobileJoystick").GetComponent <Image>();//ジョイスティック読み取り 名前が変わると動かなくなってしまう
     camerakirikae = GameObject.Find("RigidBodyFPSController").GetComponent <Camerakirikae>();
     Maincamera    = gameObject.transform.FindChild("MainCamera").gameObject;
     Jairon        = Maincamera.GetComponent <jairon>();
     bgm           = gameObject.GetComponents <AudioSource>();
 }
Пример #2
0
    // Update is called once per frame
    void Update()
    {
        if (fast)
        {
            fast           = false;
            gyrosan        = Input.gyro.attitude.eulerAngles;
            fgyrox2        = gyrosan.y;
            fgyrox         = gameObject.transform.rotation.y;
            style          = new GUIStyle();
            style.fontSize = 30;
        }
        GameObject obj = GameObject.Find("RigidBodyFPSController");

        camerakirikae = obj.GetComponent <Camerakirikae>();
        if (Input.gyro.enabled)
        {
            gyro = Input.gyro.attitude;
            //gyro = Quaternion.Euler(90, 0, 0) * (new Quaternion(-gyro.x, -gyro.y, gyro.z, gyro.w));
            //gyro = Quaternion.Euler(0, 0, 0);
            gyro       = Quaternion.Euler(90, 0, 0) * (new Quaternion(-gyro.x, -gyro.y, gyro.z, gyro.w));
            gyrosan    = gyro.eulerAngles;
            gyrosan.y += fgyrox - fgyrox2;
            gyrosan.x -= regyrox;//ここで縦の傾きを調節する
            //カメラの稼動限界を調節する部分
            gyrosanX = (gyrosan.x > 180) ? gyrosan.x - 360 : gyrosan.x;
            gyrosanY = (gyrosan.y > 180) ? gyrosan.y - 360 : gyrosan.y;
            if (genkai1.y != 0 || genkai2.y != 0)
            {
                gyrosan.x = Mathf.Clamp(gyrosanX, genkai1.x, genkai2.x);
            }
            if (genkai1.x != 0 || genkai2.x != 0)
            {
                gyrosan.y = Mathf.Clamp(gyrosanY, genkai1.y, genkai2.y);
            }
            //変更点
            gyrosan.y = (gyrosanY < 0) ? gyrosanY + 360 : gyrosanY;
            gyrosan.x = (gyrosanX < 0) ? gyrosanX + 360 : gyrosanX;
            //変更点ここまで
            //スマホの向きにカメラを傾ける
            gameObject.transform.rotation = Quaternion.Euler(gyrosan);
            if (Screen.orientation == ScreenOrientation.Portrait)
            {
                //縦持ち
                camerakirikae.Playermode = true;
            }
            else if (Screen.orientation == ScreenOrientation.LandscapeLeft || Screen.orientation == ScreenOrientation.LandscapeRight)
            {
                //横持ち(左傾け&右傾け)
                camerakirikae.Playermode = false;
            }
        }
        //camera.transform.rotation = Quaternion.AngleAxis(90.0f, Vector3.right) * Input.gyro.attitude * Quaternion.AngleAxis(180.0f, Vector3.forward);
    }
Пример #3
0
 void Update()
 {
     camerakirikae = obj2.GetComponent <Camerakirikae>();
     if (Input.GetMouseButtonDown(0))
     {
         //監視カメラを起動したかのチェック
         if (camerakirikae.Playermode)
         {
             //メインカメラからのチェック
             ray = camerakirikae.mainCamera.ScreenPointToRay(Input.mousePosition);
         }
         else
         {
             //監視カメラからのチェック
             ray = camerakirikae.HacCamera.ScreenPointToRay(Input.mousePosition);
         }
         RaycastHit hit = new RaycastHit();
         if (Physics.Raycast(ray, out hit))
         {
             GameObject obj = hit.collider.gameObject;
             if (obj == gameObject)
             {
                 if (cameracode == 0)
                 {
                     //監視カメラをジャックした場合以下の処理を行う
                     Screen.autorotateToLandscapeRight = true;
                     Screen.autorotateToLandscapeLeft  = true;
                     int i = 0;
                     //camerakirikae(監視カメラ情報)のスクリプトに自身がなければ新しく監視カメラを登録する。
                     while (camerakirikae.cameras[i] != null)
                     {
                         if (camerakirikae.cameras[i] == gameObject)
                         {
                             i = -1;
                             break;
                         }
                         i++;
                     }
                     if (i != -1)
                     {
                         camerakirikae.cameras[i] = gameObject;
                     }
                 }
             }
         }
     }
 }
Пример #4
0
    // Update is called once per frame
    void Update()
    {
        GameObject obj = GameObject.Find("RigidBodyFPSController");

        camerakirikae = obj.GetComponent <Camerakirikae>();
        if (Input.gyro.enabled)
        {
            gyro = Input.gyro.attitude;                                                                //やわらかスマホの傾きをよみとる
            //gyro = Quaternion.Euler(90, 0, 0) * (new Quaternion(-gyro.x, -gyro.y, gyro.z, gyro.w));
            gyro    = Quaternion.Euler(90, 0, 0) * (new Quaternion(-gyro.x, -gyro.y, gyro.z, gyro.w)); //スマホの向きを縦持ちに整える
            gyrosan = gyro.eulerAngles;
            //ここからカメラの角度の限界を設定している。(試作)
            if ((gyro.w < genkai1.x) && (genkai1.x != 0))
            {
                gyro.w = genkai1.x;
            }
            if ((gyro.w > genkai2.x) && (genkai2.x != 0))
            {
                gyro.w = genkai2.x;
            }
            if ((gyro.x < genkai1.y) && (genkai1.y != 0))
            {
                gyro.x = genkai1.y;
            }
            if ((gyro.x > genkai2.y) && (genkai2.y != 0))
            {
                gyro.x = genkai2.y;
            }
            //ここまでカメラの角度の限界を設定している。
            gameObject.transform.localRotation = gyro;//カメラくんをスマホの向きに向かせる
        }

        //camera.transform.rotation = Quaternion.AngleAxis(90.0f, Vector3.right) * Input.gyro.attitude * Quaternion.AngleAxis(180.0f, Vector3.forward);
        if (Screen.orientation == ScreenOrientation.Portrait)
        {
            //縦持ち
            camerakirikae.Playermode = true;
        }
        else if (Screen.orientation == ScreenOrientation.LandscapeLeft || Screen.orientation == ScreenOrientation.LandscapeRight)
        {
            //横持ち(左傾け&右傾け)
            camerakirikae.Playermode = false;
        }
    }
Пример #5
0
    // Use this for initialization
    void Start()
    {
        GameObject obj = GameObject.Find("RigidBodyFPSController");

        camerakirikae = obj.GetComponent <Camerakirikae>();
    }
Пример #6
0
    void Update()
    {
        camerakirikae = obj2.GetComponent <Camerakirikae>();
        if (Input.GetMouseButtonDown(0))
        {
            if (camerakirikae.Playermode)
            {
                //プレイヤーカメラからの判定取得
                ray = camerakirikae.mainCamera.ScreenPointToRay(Input.mousePosition);
            }
            else
            {
                //監視カメラからの判定取得
                ray = camerakirikae.HacCamera.ScreenPointToRay(Input.mousePosition);
            }
            RaycastHit hit = new RaycastHit();
            if (Physics.Raycast(ray, out hit))
            {
                rayobj = hit.collider.gameObject.ToString();
                GameObject obj = hit.collider.gameObject;
                if (obj == gameObject)
                {
                    cameraon = true;
                    stick.ok = false;
                    if (cameracode == 0)
                    {
                        Renderer ligatgrean = transform.FindChild("light").GetComponent <Renderer>();
                        ligatgrean.material = lightmaterial;
                        Light pligat = transform.FindChild("light/Point light").gameObject.GetComponent <Light>();
                        switch (setlighatcolor)
                        {
                        case ligahtcolor.nomal:
                            pligat.color = Color.green;
                            break;

                        case ligahtcolor.alert:
                            pligat.color = Color.red;
                            break;
                        }
                        //初めて自分がタッチされたとき
                        //カメラの向きによりカメラモードの変更を可能にする
                        Screen.autorotateToLandscapeRight = true;
                        Screen.autorotateToLandscapeLeft  = true;
                        int i = 0;
                        while (camerakirikae.cameras[i] != null)
                        {
                            if (camerakirikae.cameras[i] == gameObject)
                            {
                                i = -1;
                                break;
                            }
                            i++;
                        }
                        if (i != -1)
                        {
                            //camerakirikaeのスクリプトに
                            //新しいカメラの情報を入れる
                            camerakirikae.cameras[i] = gameObject;
                        }
                    }
                }
            }
        }
    }
Пример #7
0
 // Update is called once per frame
 void Update()
 {
     camerakirikae = obj.GetComponent <Camerakirikae>();
 }
Пример #8
0
 // Use this for initialization
 void Start()
 {
     Input.gyro.enabled = true;
     camerakirikae      = player.GetComponent <Camerakirikae>();
     stick = GameObject.Find("MobileSingleStickControl").GetComponent <stickset>();
 }