full Rotations of an object

I’m trying to find out the amount of full rotations (spins) in the x axis my object is doing. So far i have…

if(m_bGetRotOnce)
{
m_fGetStartXRotation = gGlobals.GetCurrentObject().transform.localEulerAngles.x;
m_fGetCurXRotation = 0;
m_bGetRotOnce = false;
}

float localX = gGlobals.GetCurrentObject().transform.rotation.x;
m_fGetCurXRotation += localX - m_fGetStartXRotation;

if(m_fGetCurXRotation >= 360)
{
m_sNumberOfFlips++;
m_fGetCurXRotation = 0;
}

This counts m_sNumberOfFlips too often, i can see how it’s going wrong, but i was wondering if anyone had a solution to this.

Thanks.

gGlobals.GetCurrentObject().transform.rotation.x is not the angle in degree of the last rotation, it’s the current x component of the quaternion of this object. You should do that instead :

int nbRot = (int)(...).rotation.eulerAngles.x / 360;