I have a script that lets the player rotate on the y axis while it is in the air. I am trying to get the total amount of rotation while in the air. It seems that once the global rotation of the object exceeds 360 degrees, it resets back to 0, so I get inaccurate results. The player has a character controller if that somehow matters. Here is my code:
Move:
transform.Rotate(0,turnit, 0);
Get rotation:
var controller : CharacterController = GetComponent(CharacterController);
/////////////// 360 /////////////////
if (controller.isGrounded == false) {
if (canStartChecking == true) {
three_sixty();
}
}
if (controller.isGrounded) {
if (canStartChecking == false) {
canStartChecking = true;
rotY2 = transform.rotation.eulerAngles.y;
fullRot = Mathf.Abs(rotY2 - rotY);
//Debug.Log(fullRot);
if (fullRot > 160 && fullRot < 200) {
Debug.Log("180!");
}
if (fullRot > 340 && fullRot < 380) {
Debug.Log("360!");
}
}
}
//////////////// END OF 360 ////////////////
}
function three_sixty () {
canStartChecking = false;
rotY = transform.rotation.eulerAngles.y;
var controller : CharacterController = GetComponent(CharacterController);
}
I realize some of this is probably bad code, but its not final. Thanks in advance!