Control the camera through a phone's accelerometer

I want to control the main camera of the game through the phone’s accelerator only (don’t talk about gyro). Target OS are both Android and iOS. The idea is that as you walk around and tilt around your phone, so does the main camera in the game world.

Below I have pieced out together some code from other answers. Right now I can control the orientation mechanism(as in tilting phone tilts camera) but I still can’t handle the movement(as in translating to another position).

float xRot, yRot, zRot;
public float rotSpeed = 20f;

void FixedUpdate () {
	
		xRot = Input.acceleration.z * -180f;
		yRot = Input.acceleration.x * -180f;
		zRot = 0f;
		Quaternion quat = transform.rotation;
		transform.rotation = Quaternion.Lerp (quat, Quaternion.Euler (new         Vector3 (xRot, yRot, zRot)), Time.deltaTime * rotSpeed);
		transform.Translate (Input.acceleration.x*Time.deltaTime*0.5f, (Input.acceleration.y + 9.8f)*Time.deltaTime*0.5f, Input.acceleration.z*Time.deltaTime*0.5f); 
	}

Moving the phone forward does not move the camera forward. Moving the phone backward does not move the camera backward and etc. What is wrong with this portion of the code?

I’m no expert and the question is pretty old but you have to move the player to move the camera (If it is a children of the player), you are transforming the rotation of the camera but not the position, hope it’s helpful

You can use your accelerometer to Do the rotation. All devices can be compatible for VR Or to rotate the camera with accelerometer, because all devices have accelerometer. And works on all axes. Thanks to this asset: