I wrote this script on my own and it works fine. However, it cannot rotate objects smoothly. How can make it so it can rotate the object and its parent smoothly?
I use this script to rotate my camera vertically and its parent horizontally:
public class MyCamera : MonoBehaviour {
public float rotationSpeed = 100;
public Transform parent;
void Update() {
transform.localEulerAngles += new Vector3(Input.GetAxis("Mouse Y") * rotationSpeed * Time.deltaTime, 0, 0);
parent.transform.localEulerAngles += new Vector3(0, Input.GetAxis("Mouse Y") * rotationSpeed * Time.deltaTime. 0);
}
}