hey guys , someone please tell me how can i look at a target on 2 axis but clamp the the object’s rotation ,to only rotate from -45 to 45 on x and -60 to 60 on y axis.
also need the looking process to be smooth and use some kinda looking speed variable
i used this script to look at target and clamp the rotation, but it’s not working right ):
void Update()
{
Quaternion OriginalRot = transform.rotation;
transform.LookAt(target);
Quaternion NewRot = transform.rotation;
transform.rotation = OriginalRot;
transform.rotation = Quaternion.Lerp(transform.rotation, NewRot, speed * Time.deltaTime);
transform.eulerAngles = new Vector3(Mathf.Clamp(transform.eulerAngles.y, minimumX,
minimumX), Mathf.Clamp(transform.eulerAngles.y, minimumY, maximumY), 0);
}
thanks