title: How to move the camera using gyro in Unity
body: <p>I have a Unity game with landscape orientation. I want to be able to rotate the camera to the left and to the right. More, I want to move the camera back and forward according to the gyro tilt in the y-axis, and the total vector of rotating right or left. In other words, I want to be able to move the camera like a person walking in a room. The camera is the main player of my game.</p>
  
  <p>This is what I tried to do:</p>
  
  <pre><code>GameObject CamParent;
  Rigidbody RB;
  
  void Start()
  {
  
      CamParent = new GameObject("CamParent");
      CamParent.transform.position = this.transform.position;
      this.transform.parent = CamParent.transform;
      Input.gyro.enabled = true;
      RB = this.GetComponent&lt;Rigidbody&gt;();
  }
  
  void Update()
  {
      CamParent.transform.Rotate(0, -Input.gyro.rotationRateUnbiased.y, 0);
      this.transform.Rotate(-Input.gyro.rotationRateUnbiased.x, 0,0);
      float Z = -Input.gyro.userAcceleration.z;
      RB.AddForce(new Vector3(0,0,Z)*10);
  }
  </code></pre>