VRゲームをUnityで使って作っているのですが、Card boardのためコントローラなしということで傾きで移動できるという
https://qiita.com/yukatou/items/082aaae614c4b6b8de5d
を参考に作ったのですが
C#
1using UnityEngine; 2using System.Collections; 3 4public class GameScript : MonoBehaviour { 5 public Camera mainCamera; 6 public float moveSpeed = 2.0f; 7 public float moveAngleX = 20.0f; 8 9 float yOffset; 10 11 // Use this for initialization 12 void Start () { 13 yOffset = mainCamera.transform.position.y; 14 } 15 16 // Update is called once per frame 17 void Update () { 18 19 // 1.カメラの傾きを取得 20 float x = mainCamera.transform.eulerAngles.x; 21 Debug.Log (x); 22 23 // 2.ある角度以内であれば前進させる 24 if (moveAngleX < x && x < 90.0f) { 25 moveFoward (); 26 } 27 } 28 29 private void moveFoward() { 30 Vector3 direction = new Vector3 (mainCamera.transform.forward.x, 0, mainCamera.transform.forward.z).normalized * moveSpeed * Time.deltaTime; 31 Quaternion rotation = Quaternion.Euler (new Vector3 (0, -mainCamera.transform.rotation.eulerAngles.y, 0)); 32 mainCamera.transform.Translate (rotation * direction); 33 mainCamera.transform.position = new Vector3 (mainCamera.transform.position.x, yOffset, mainCamera.transform.position.z); 34 } 35}
このスクリプトで下を向くと前に進むというもので実際にUnityのビューでキチンと動作していたもののAndroidに入れてみるものの下を向いても前に進まず困っています
どうすればいいでしょうか
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。