Hi there. I dunno , i have achieved this before , but for some strange reason , no matter what i try i can not get this to work again.
I have the Main camera attached to my character head bone. I am trying to find a way to increase decrease localEuelerAngles as a look up down with the mouse. The problem seems to be that localAngles ends @ 360 , and 0, so i cant find a way to legitly test and force a min , max rotation.
Heres an example, which i know doesnt work.
if(camTransform.localEulerAngles.x >= 250 || camTransform.localEulerAngles.x <= 45 || camTransform.localEulerAngles.x == 0){
camTransform.localEulerAngles.x += Input.GetAxis("Mouse Y") / bones.neckTurnSpeed;
}
else if(camTransform.localEulerAngles.x < 250 camTransform.localEulerAngles.x > 225){
camTransform.localEulerAngles.x = 250;;
}
else if(camTransform.localEulerAngles.x > 45 camTransform.localEulerAngles.x < 65){
camTransform.localEulerAngles.x = 45;
}
As i said , i have had this working before no problem , but for some reason , i just cant get this camera to cooperate, and i was sure i just used a Mathf.Clamp on the rotation, but i dont really understand why i cant control it this time around.
If i attempt camTransform.Rotate(Input.GetAxis(“Mouse Y”), 0, 0); i cant seem to find a way to set its min max either. Litle tip would be awsome , thanks.
PS: another one not working.
totalNeckTurn -= Input.GetAxis("Mouse Y")* bones.neckTurnSpeed;
if(totalNeckTurn > bones.minNeckTurn totalNeckTurn < bones.maxNeckTurn){
camTransform.localEulerAngles.x = totalNeckTurn;
}
One lats thing about this , what is making it very complicated , is that of course the rig does not have all of its bones facing a unity alignment , and so therefor , when the cameras localEulerAngles are accessed after it has been parented to the camera , they dont seem to be matching up at all to where they would be if it was just a solo transform. I really dont understan why im having such a issue with the camera this time around.