- Home /
 
               Question by 
               unity_9d5-VgjizaCUeQ · Dec 26, 2017 at 09:48 AM · 
                androidinputsearch  
              
 
              I can't find the inputs
Hello I have downloaded a script to move my cube around but when I want to convert it to android I can't find the inputs to change them. On pc the cube moves with the left and right arrow. You can see that my touch screen setting are there (44 - 55). How do I fix this?
 {
 
     public float rotationPeriod = 0.3f;     // 隣に移動するのにかかる時間
     public float sideLength = 1f;           // Cubeの辺の長さ
     public event System.Action OnPlayerDeath;
 
     bool isRotate = false;                  // Cubeが回転中かどうかを検出するフラグ
     float directionX = 0;                   // 回転方向フラグ
     float directionZ = 0;                   // 回転方向フラグ
 
     Vector3 startPos;                       // 回転前のCubeの位置
     float rotationTime = 0;                 // 回転中の時間経過
     float radius;                           // 重心の軌道半径
     Quaternion fromRotation;                // 回転前のCubeのクォータニオン
     Quaternion toRotation;                  // 回転後のCubeのクォータニオン
 
     // Use this for initialization
     void Start()
     {
 
         // 重心の回転軌道半径を計算
         radius = sideLength * Mathf.Sqrt(2f) / 2f;
 
     }
 
     // Update is called once per frame
     void Update()
     {
 
         float x = 0;
         float y = 0;
 
         // キー入力を拾う。
         
         if (x == 0)
         {
             y = Input.GetAxisRaw("Horizontal");
         }
         foreach (Touch touch in Input.touches)
         {
             if ((touch.position.x > Screen.width / 2) && (touch.phase == TouchPhase.Began))
             {
               
             }
 
             if ((touch.position.x > Screen.width / 2) && (touch.phase == TouchPhase.Began))
             {
                
             }
         }
 
 
         // キー入力がある かつ Cubeが回転中でない場合、Cubeを回転する。
         if ((x != 0 || y != 0) && !isRotate)
         {
             directionX = -y;                                                             // 回転方向セット (x,yどちらかは必ず0)
             directionZ = -x;                                                             // 回転方向セット (x,yどちらかは必ず0)
             startPos = transform.position;                                              // 回転前の座標を保持
             fromRotation = transform.rotation;                                          // 回転前のクォータニオンを保持
             transform.Rotate(directionZ * 90, 0, directionX * 90, Space.World);     // 回転方向に90度回転させる
             toRotation = transform.rotation;                                            // 回転後のクォータニオンを保持
             transform.rotation = fromRotation;                                          // CubeのRotationを回転前に戻す。(transformのシャローコピーとかできないんだろうか…。)
             rotationTime = 0;                                                           // 回転中の経過時間を0に。
             isRotate = true;                                                            // 回転中フラグをたてる。
         }
     }
 
     void FixedUpdate()
     {
 
         if (isRotate)
         {
 
             rotationTime += Time.fixedDeltaTime;                                    // 経過時間を増やす
             float ratio = Mathf.Lerp(0, 1, rotationTime / rotationPeriod);          // 回転の時間に対する今の経過時間の割合
 
             // 移動
             float thetaRad = Mathf.Lerp(0, Mathf.PI / 2f, ratio);                   // 回転角をラジアンで。
             float distanceX = -directionX * radius * (Mathf.Cos(45f * Mathf.Deg2Rad) - Mathf.Cos(45f * Mathf.Deg2Rad + thetaRad));      // X軸の移動距離。 -の符号はキーと移動の向きを合わせるため。
             float distanceY = radius * (Mathf.Sin(45f * Mathf.Deg2Rad + thetaRad) - Mathf.Sin(45f * Mathf.Deg2Rad));                        // Y軸の移動距離
             float distanceZ = directionZ * radius * (Mathf.Cos(45f * Mathf.Deg2Rad) - Mathf.Cos(45f * Mathf.Deg2Rad + thetaRad));           // Z軸の移動距離
             transform.position = new Vector3(startPos.x + distanceX, startPos.y + distanceY, startPos.z + distanceZ);                       // 現在の位置をセット
 
             // 回転
             transform.rotation = Quaternion.Lerp(fromRotation, toRotation, ratio);      // Quaternion.Lerpで現在の回転角をセット(なんて便利な関数)
 
             // 移動・回転終了時に各パラメータを初期化。isRotateフラグを下ろす。
             if (ratio == 1)
             {
                 isRotate = false;
                 directionX = 0;
                 directionZ = 0;
                 rotationTime = 0;
             }
         }
     }
     void OnTriggerEnter(Collider triggerCollider)
     {
         if (triggerCollider.tag == "Falling Block")
         {
 
 
             if (OnPlayerDeath != null)
             {
                 OnPlayerDeath();
             }
            
             Destroy (gameObject);
         }
     }
 }
               Comment
              
 
               
              Answer by unity_9d5-VgjizaCUeQ · Dec 26, 2017 at 10:23 AM
English version
 public class move1 : MonoBehaviour
 {
 
     public float rotationPeriod = 0.3f;     // Time taken to move next to
     public float sideLength = 1f;           // Edge length of Cube
     public event System.Action OnPlayerDeath;
 
     bool isRotate = false;                  // Flag to detect whether the Cube is rotating or not
     float directionX = 0;                   // Rotation direction flag
     float directionZ = 0;                   // Rotation direction flag
 
     Vector3 startPos;                       // Position of Cube before rotation
     float rotationTime = 0;                 // Time lapse during rotation
     float radius;                           // Orbital radius of center of gravity
     Quaternion fromRotation;                // Quotanion of Cube before rotation
     Quaternion toRotation;                  // Quotanion of Cube after rotation
 
 
     // Use this for initialization
     void Start()
     {
 
         // Calculate rotational orbit radius of center of gravity
         radius = sideLength * Mathf.Sqrt(2f) / 2f;
 
     }
 
     // Update is called once per frame
     void Update()
     {
 
         float x = 0;
         float y = 0;
 
         // pick up the key input.。
 
         if (x == 0)
         {
             y = Input.GetAxisRaw("Horizontal");
         }
         foreach (Touch touch in Input.touches)
         {
             if ((touch.position.x < Screen.width / 2) && (touch.phase == TouchPhase.Began))
             {
                 ;
             }
 
             if ((touch.position.x > Screen.width / 2) && (touch.phase == TouchPhase.Began))
             {
                 ;
             }
         }
 
         // If there is a key input and the Cube is not rotating, rotate the Cube.        
         if ((x != 0 || y != 0) && !isRotate)
         {
             directionX = -y;                                                             // Rotation direction set (either x or y must be 0)
             directionZ = -x;                                                             // Rotation direction set (either x or y must be 0)
             startPos = transform.position;                                              // Maintain coordinates before rotation
             fromRotation = transform.rotation;                                          // Keep quaternion before rotation
             transform.Rotate(directionZ * 90, 0, directionX * 90, Space.World);         // Rotate 90 degrees in the direction of rotation
             toRotation = transform.rotation;                                            // Retain quaternion after rotation
             transform.rotation = fromRotation;                                          // Return Cube Rotation before rotation. (Is not it a shallow copy of transform or ...?)
             rotationTime = 0;                                                           // The elapsed time during rotation is set to 0
             isRotate = true;                                                            // Make a rotating flag
         }
     }
 
     void FixedUpdate()
     {
 
         if (isRotate)
         {
 
             rotationTime += Time.fixedDeltaTime;                                    // Increase elapsed time
             float ratio = Mathf.Lerp(0, 1, rotationTime / rotationPeriod);          // Percentage of current elapsed time relative to time of rotation
 
             // Move
             float thetaRad = Mathf.Lerp(0, Mathf.PI / 2f, ratio);                   // Rotation angle in radians
             float distanceX = -directionX * radius * (Mathf.Cos(45f * Mathf.Deg2Rad) - Mathf.Cos(45f * Mathf.Deg2Rad + thetaRad));      // Distance traveled on X axis. The sign of - is for aligning the direction of movement with the key.
             float distanceY = radius * (Mathf.Sin(45f * Mathf.Deg2Rad + thetaRad) - Mathf.Sin(45f * Mathf.Deg2Rad));                        // Y axis movement distance
             float distanceZ = directionZ * radius * (Mathf.Cos(45f * Mathf.Deg2Rad) - Mathf.Cos(45f * Mathf.Deg2Rad + thetaRad));           // Z axis travel distance
             transform.position = new Vector3(startPos.x + distanceX, startPos.y + distanceY, startPos.z + distanceZ);                       // Set the current position
 
             // rotation
             transform.rotation = Quaternion.Lerp(fromRotation, toRotation, ratio);      // Set current rotation angle with Quaternion.Lerp (what a useful function)
 
             // Initialize each parameter at the end of movement / rotation.Lower the isRotate flag.
             if (ratio == 1)
             {
                 isRotate = false;
                 directionX = 0;
                 directionZ = 0;
                 rotationTime = 0;
             }
         }
     }
     void OnTriggerEnter(Collider triggerCollider)
     {
         if (triggerCollider.tag == "Falling Block")
         {
 
 
             if (OnPlayerDeath != null)
             {
                 OnPlayerDeath();
             }
            
             Destroy (gameObject);
         }
     }
 }
Your answer
 
 
              koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                