So, as shown in the code attached below I am having a problem checking the Z axis of my gameobject. The odd part is that it’s just the line: "CameraBody.transform.eulerAngles.z <= rotation2 " at the bottom, that would be line #52. If I take that away and just check the boolean then the if statement goes off. But it seems for some reason that the addition of checking the angle doesn’t work. So for example Rotation 2 is set at -50 and the cameraBody is rotating towards negative along the Z-axis. Once the Camera passes -50 and continues lower into the negatives the if statement doesn’t go off. But upon switching the switch statement case to “greater than” so that line #39, the if statement will go off just fine. Any ideas or any already answered questions would be appreciated. Thank you!
void Update () {
QuestionMark ();
if (detectingPlayer == false && detectedplayer == false) {
switch (Operator1) {
case ">":
if (ReverseRotation == false && cameraBody.transform.eulerAngles.z >= rotation1) {
cameraBody.transform.localRotation *= Quaternion.Euler (0, 0, 0.2f);
//Debug.Log ("Positive Rotation 1");
} else if(ReverseRotation != true) {
Debug.Log ("Making reverse rotation true #1");
ReverseRotation = true;
}
if(ReverseRotation == true) {
//ReverseRotation = true;
cameraBody.transform.localRotation *= Quaternion.Euler (0, 0, -0.2f);
//Debug.Log ("Negative Rotation 1");
}
break;
case "<":
if (ReverseRotation == false && cameraBody.transform.eulerAngles.z <= rotation1) {
cameraBody.transform.localRotation *= Quaternion.Euler (0, 0, 0.2f);
//Debug.Log ("Positive Rotation 2");
} else if(ReverseRotation != true) {
Debug.Log ("Making reverse rotation true #2");
ReverseRotation = true;
}
if(ReverseRotation == true) {
//ReverseRotation = true;
cameraBody.transform.localRotation *= Quaternion.Euler (0, 0, -0.2f);
//Debug.Log ("Negative Rotation 1");
}
break;
}
switch (Operator2) {
case ">":
//Debug.Log ("In greater than, Operator 2 A");
if (cameraBody.transform.eulerAngles.z >= rotation2 && ReverseRotation == true) {
ReverseRotation = false;
//cameraBody.transform.localRotation *= Quaternion.Euler (0, 0, -0.4f);
Debug.Log ("Reverse Rotation = false 3");
}
break;
case "<":
Debug.Log ("In less than, Operator 2 B");
Debug.Log ("Reverse rotation is: " + ReverseRotation);
//Debug.Log ("Rotation 2 is: " + rotation2);
if (cameraBody.transform.eulerAngles.z <= rotation2 && ReverseRotation == true) {
ReverseRotation = false;
//cameraBody.transform.localRotation *= Quaternion.Euler (0, 0, -0.4f);
Debug.Log ("Reverse Rotation = false 4");
}
break;
}