I tried this with the challenge, and had some difficulty. The problem was that even a very small negative value, like -0.1, were giving me large rotations of 359.9, which of course is more than the threshold and resulted in a “fallen” pin.

So I watched Ben’s way, copied his solution, and had the same problem. So I made some modifications to the math. Here is my IsStanding() method:

public bool IsStanding(){

Vector3 rotationInEuler = transform.rotation.eulerAngles;

float tiltInX = 180f - Mathf.Abs (180f - rotationInEuler.x);

float tiltinZ = 180f - Mathf.Abs (180f - rotationInEuler.z);

if (tiltInX < standingThreshold && tiltinZ < standingThreshold) {

return true;

}

return false;

}

The difference is in the calculation of tiltInX and tiltInY. The (180 - rotation) gives the angle from the “south pole”, so to speak, and Mathf.Abs ensures that it is represented as a positive value. So 10 degrees will give you a value of 170, and -10 degrees (which is 350 degrees to Unity) will also give you a value of 170. Subtracting this number from 180 gives you 10, which is the number of degrees from 0 (standing).

I checked it out, and using a Boolean in the update method, made it display “1 Pin fell”, “2 Pin fell”, etc. It works when I swipe, and when I manage to knock down a ball or two.