This has been bugging me for ages too, but I may have stumbled upon a workaround that will at the very least allow mw to complete the Bowlmaster lesson. This is by no means elegant, but it seems to be working for me.
So, what was happening for me was, the tilt values were increasing whilst the pins were stationary due to the dreaded shake/jitter, they were going up to ± 9 in most cases which exceeded the threshold of 3 and reported a fallen pin. I tried increasing the threshold to 12, but I was also getting a random tilt value in both X & Z of 359.0000, and this would happen only once per pin? and was always 359?
So what I did was to increase my threshold to 50, I figure if a pin has fallen over then the tilt values would be more than 50 anyway and it is sufficiently high enough to deal with the ±9 tilt values from the shaking.
I also added another test on the tilt values to check they were < 350, that eliminates the false return from the 359 value, and if they were then I continue with the normal check. I also had to remove the Mathf.Abs() also to get it to work.
Like I said, not elegant, and I don’t fully understand why it’s working for me, but it’s allowing me to mitigate the shaking and continue with the lesson.
public bool IsStanding()
{
Vector3 rotationInEuler = transform.rotation.eulerAngles;
//float tiltInX = Mathf.Abs(rotationInEuler.x);
//float tiltInZ = Mathf.Abs(rotationInEuler.z);
float tiltInX = rotationInEuler.x;
float tiltInZ = rotationInEuler.z;
if (tiltInX < 350 && tiltInZ < 350)
{
if (tiltInX < standingThreshold && tiltInZ < standingThreshold)
{
print(name + " Stading Tall!!!");
return true;
}
else
{
print(name + " Fell Over!!! <<<<<<<<<<<<<<<<<<<<<<<<");
return false;
}
}
return true;
}