How to use Android Accelerometer(Left and right tilt) to turn a sphere object and camera in that direction?

While controlling a sphere ball through accelerometer, while turning left or right I want both the object and the camera to turn towards that direction. Current State : ball moving in that direction and camera is only looking at the ball, not in the direction in which it is moving.
I have been trying to look solutions to this problem for the past several days; Any help would be much appreciated. :slight_smile:

Ball Controller:

curAc = Vector3.Lerp(curAc, Input.acceleration-zeroAc, Time.deltaTime/smooth);
				GetAxisV = Mathf.Clamp(curAc.y * sensV, -1, 1);
				GetAxisH = Mathf.Clamp(curAc.x * sensH, -1, 1);

				Vector3 movement = new Vector3 (GetAxisH, 0.0f, GetAxisV);

				GetComponent<Rigidbody>().AddTorque(movement * speedAc);

Camera Controller:

void Start()
	{
		playerOffset = transform.position - player.transform.position;
	}

	
	void LateUpdate()
	{
		transform.position = player.transform.position + playerOffset;
	}

Iā€™m the OP, but I solved the problem, atleast to my satisfaction.
Creating an empty game object and making the ball and the camera child of it worked for me. The hierarchy :

  • Empty Game Object(Container)(Parent)

  • Ball(Child 1)

  • Camera(Child 2)

Then, apply the movement controller script on that empty game object. Hope this helps to someone in the future. Cheers :slight_smile: