Z rotation in flux

Hi Guys,

I am having some trouble with lecture “Pins Have Settled 1” in that the Z rotation of the pins seems to be influx.

I have placed the following code into my Pin IsStanding() method. Note I am using Unity 5.5.0f3 and this apparently this doesn’t give back negative eulerAngles. Though when I am inspecting the rotation of the Z axis on a single pin it seems to be quivering and moving. Though I am unsure why this would make the rotation go as high as 70 degress.

public class Pin : MonoBehaviour
{
    public float standingThreshold = 3f;

public bool IsStanding()
{
    float newX = 270f - transform.rotation.eulerAngles.x;
    float tiltX = (newX < 180f) ? newX : 360 - newX;
    float tiltZ = (transform.rotation.eulerAngles.z < 180f) ? transform.rotation.eulerAngles.z : 360 - transform.rotation.eulerAngles.z;

    if(tiltX > standingThreshold)
    {
        print("X Failed");
    }
    if (tiltZ > standingThreshold)
    {
        print("Z Failed");
    }
    return (tiltX < standingThreshold && tiltZ < standingThreshold);
}
}
2 Likes

I figured out that the gravity was set too high and this caused the pins to wobble quite a bit. So I have fixed it to the -20 value that was in the lecture and this has fixed the issue.

1 Like

Thanks for posting your issue, I am using 5.3.2 and was having a similar issue. This help me work through my problem and got the pins counting again.

Privacy & Terms