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.
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;
}