here is a third-person camera, her MouseOrbit script. I need to limit the angle of rotation of the camera along the axis X, with respect to the Target. Target - an object rigidbody.
You can do this:
add to script variables
public var xMinLimit : float = -120;
public var xMaxLimit : float = 120;
Add in Lateupdate
x = ClampAngle(x, xMinLimit, xMaxLimit);
and slightly lower values multiply rotation
var baseRotation : Quaternion = target.rotation;
rotation = baseRotation * Quaternion.Euler (y, x, 0);
Everything works, the rotation angle is limited as it is necessary.
The problem is that the camera must not be attached to the object rigidbody.
Luggage must not depend on the rotation Target.
Need to angle limited, but the camera was free.
I’ve tried a lot of things, but nothing happens. Please help.
Thanks in advance for your help.