# is there any way to get a sane number on an objects current y rotation?

Want to build a clock, rotate a plane, how can I see when the plane is rotated 0, 90, 180, 270 degrees etc? (I would like to read these rotation states then do other actions and so on)

All I get is a snapping from 90 to 270 in the readout. Or worse.

Is there any sane way to do this without descending into madness?

I think this should do the trick:

``````var previousSection : int;
var baseY : float;
var currentY : float;

function Awake()
{
baseY = transform.eulerAngles.y;
previousSection = Mathf.RoundToInt(transform.eulerAngles.y - baseY) / 90;
}

function Update()
{
currentSection = Mathf.RoundToInt(transform.eulerAngles.y - baseY) / 90;
if ( currentSection != previousSection )
{
previousSection = currentSection;
Debug.Log("New Section! = " + currentSection);
}
}
``````

not working for me entirely, seems to dump 0 & 3 then 2 & 1 at the same time in the debug. I added the following:

``````var previousSection : int;
**var currentSection : int;**
var baseY : float;
var currentY : float;

function Awake()
{
baseY = transform.eulerAngles.y;
previousSection = Mathf.RoundToInt(transform.eulerAngles.y - baseY) / 90;
}

function Update()
{
**transform.Rotate(0, -1, 0);**
currentSection = Mathf.RoundToInt(transform.eulerAngles.y - baseY) / 90;
if ( currentSection != previousSection )
{
previousSection = currentSection;
Debug.Log("New Section! = " + currentSection);
}
}
``````