Below are my Code to make the Object facing the Camera but I wanna Clamp the Object rotation min and max rotation to -45 degree and 45 degree
function Update () {
var fwd = Camera.main.transform.forward;
fwd.y = 0.0;
transform.rotation = Quaternion.LookRotation(fwd);
}
Here, check this for rotation clamp,
Also you can use transform.lookAt with lookrotation to look at object, i use this piece of code
public static void LookAtObject(Transform obj, float m_PopDistance)
{
transform.rotation = Quaternion.LookRotation (obj.forward);
transform.position = obj.position + obj.forward * m_PopDistance;
transform.LookAt(2 * transform.position - obj.position);
}