//Inside your updateloop, add the following code:
//First, get the mouse position
Vector2 mousePosition = new Vector2 (
Input.GetAxis("MouseX"),
Input.GetAxis("MouseY")
);
//Then, use unity's built-in lookAt function to do all the math for you:
transform.LookAt(mousePosition);
//Inside your updateloop, add the following code:
//First, get the mouse position
Vector2 mousePosition = new Vector2 (
Input.GetAxis("Mouse X"),
Input.GetAxis("Mouse Y"))
);
//Then, use unity's built-in lookAt function to do all the math for you:
transform.LookAt(mousePosition);