Clamp the X axis using transform.RotateAround()?

Greetings :roll_eyes:

I’m using this bit of code to rotate my camera around the player on the X axis:

// Set axis in accordance to local direction
Vector3 _x = transform.TransformDirection(Vector3.right);
// player.position = pivot, _x = axis, lookVect.y = speed
transform.RotateAround(player.position, _x, lookVect.y);

It’s working great so far, but I want to limit how far up and down you can rotate the cam, and I can’t find a way to use Mathf.Clamp, any suggestions?

This seems like a convoluted way of setting Camera rotation, I would rather do something like this.

float speed = Mathf.Clamp(transform.localEulerAngles.x + lookVect.y, min, max);

transform.localRotation = Quaternion.Euler(speed, transform.localEulerAngles.y, transform.localEulerAngles.z);