How would I check if an object has exceeded a certain angle?

42 views Asked by At

I am working on an active ragdoll system and I want to make it so that the character goes completely limp after leaning too forwards or backwards. I do have a script for checking the character's hip rotation on the x axis but it seems to not work correctly.

I have searched up the problem, looked into the Unity Documentation but I still can't find a solution.

My code:

// sphereCheckOrigin is the character's hips
// I have tried to play with > and < but it still didn't work

if(sphereCheckOrigin.transform.eulerAngles.x < 50|| sphereCheckOrigin.transform.eulerAngles.x < -50)
        {
            Debug.Log("unbalanced");
        }
        else
        {
            Debug.Log("balanced");
        }
0

There are 0 answers