how i can Determine Main camera rotation between 20 and -20 (i mean i want the rotation <20 )
sorry for question , i,m still new in unity
var cameraPivot : Transform ;
if(cameraPivot.rotation.x>=20){
cameraPivot.rotation.x = 20 ;
,
how i can Determine Main camera rotation between 20 and -20 (i mean i want the rotation <20 )
sorry for question , i,m still new in unity
var cameraPivot : Transform ;
if(cameraPivot.rotation.x>=20){
cameraPivot.rotation.x = 20 ;
,
Your code is a good start. You first need to convert the rotation from a Quaternion (w, x, y, z) to Eular (x, y, z). Then, like you tried, figure out if the x rotation is out of bounds and if it is then move it to either 20 or -20 (340).
Vector3 rotation=cameraTransform.rotation.eulerAngles;
if(20<rotation.x&&rotation.x<340){
if(rotation.x<180){
cameraTransform.rotation=Quaternion.Euler(20, rotation.y, rotation.z);
}
else {
cameraTransform.rotation=Quaternion.Euler(340, rotation.y, rotation.z);
}
}