Mapping accelerometer to Camera's position

This seems simple enough, but I am having some problems with it. I am trying to map the accelerometer to a first person camera. The goal is have the crosshairs (which i can just parent to the camera) move as the player tilts their device.

I understand how to access the accelerometer x, y, and z but I cannot figure out how to make the camera work with these numbers (if that is even possible)


Try using Gyroscope. Something like this: camera.transform.rotation = Input.gyro.attitude;
Or do you need just the up-down motion of the camera? If so, try using the following code in your camera script:

float hRotation = 0.0f;    //Horizontal angle
float vRotation = 0.0f;   //Vertical rotation angle of the camera
float cameraMovementSpeed = 0.02f;
void Update() {
     hRotation -= Input.acceleration.y * cameraMovementSpeed;
     vRotation += Input.acceleration.x * cameraMovementSpeed;
     transform.rotation = Quaternion.Euler(vRotation, hRotation, 0.0f);


It’s Possible do it with accelerometer, you can rotate camera with the accelerometer. On all axes.
With this, a virtual reality application works on all phones: