Hey, I figured I’d put out my solution to calculating IsStanding
, as I think it simplifies the other solutions I’ve seen. I’d also like some feedback, as I’m worried my solution my be oversimplifying the problem, and be missing something.
public bool IsStanding()
{
float tiltAngle = Quaternion.Angle(transform.rotation, Quaternion.identity);
return (tiltAngle < standingThreshold);
}
This one uses Quaternion.Angle
, which is a static method that just gives the difference between two rotations in degrees. It seems to account for negative rotation (like getting 355 when the rotation is -5) and it always returns the value as absolute. It compares the Pin’s angle to Quaternion.identity
, which I understand as the equivalent of “up” in world space.
Is there something I’m missing with this? Any feedback would be appreciated, as I’m quite new to the concepts of Quaternions and Euler angles.