im new to unity scripting, and now am building upon "Roll a Ball" example in unity training. I wanted to make the camera rotate around the ball in the scene in Y axis, when mouse is moved, and watched some tutorials on it, and eventually wrote the code below. but it doesn't rotate around the ball. instead it does a simple rotate in place. camera still moves with the ball though. what am i doing wrong?
public class CameraController : MonoBehaviour {
public GameObject Player;
private Vector3 offset;
public float moveSpeed;
private Vector3 point;
void Start () {
offset = transform.position - Player.transform.position;
point = Player.transform.position;
transform.LookAt(point);
}
void Update()
{
float mouseMovement = Input.GetAxis("Mouse X");
transform.RotateAround(point, new Vector3(0f, mouseMovement, 0f) , moveSpeed * Time.deltaTime);
}
void LateUpdate()
{
transform.position = Player.transform.position + offset;
}
}