# Get an eular angle between 0 and 360 after calculations

## Summary of my issue

Hello, I believe I am making a mistake. What I am trying to do is limit a rotation of an object in either two directions. Here is some code:
``````        if (startTower.transform.eulerAngles.y > 90 && startTower.transform.eulerAngles.y < 270)
{
Debug.Log(startTower.transform.eulerAngles.y + 90);
}
else if (startTower.transform.eulerAngles.y < 60 || startTower.transform.eulerAngles.y > 300)
{
Debug.Log(startTower.transform.eulerAngles.y + 90);
}
``````

### The issue

Now the issue with the above, is that at 360, it adds 90. so it's 450 and I want 450-360, = 90. So I want 90. So is there a way to convert 450 into 90 while doing the calculation?

Or more specifically, is there a way to always get the degrees between 0 and 360, even if I add 90?

Note: You don’t need to do this, I’ll accept the answer if the above is right.
So, if you are feeling generous, from the picture below, I want the wall to only appear on those two sides, where the blue arrows are. So left of the wall, or right of the wall.

So my plan is to replace the debug.log, with Mathf.Clamp, and give it 60 degrees leeway. If you would like to give a better solution than my idea, I am willing to try it.

End of generosity

Any help would be greatly appreciated

Try it:

``````    public static float Clamp0360(float eulerAngles)
{
float result = eulerAngles - Mathf.CeilToInt(eulerAngles / 360f) * 360f;
if (result < 0)
{
result += 360f;
}
return result;
}
``````

It would be quicker and more concise to just use the remainder operator.

``````eulerAngles %= 360;
``````
``````        Vector3 targetDir = targetPos - originPos;

////180 to -180 angle
float angle = Vector3.SignedAngle(targetDir.normalized, new Vector3(0f, 0f, 1f), Vector3.down);
//                                                        //direction                   /Look vector                   /Rotate vector
////0 to 360 angle
float fullAngle = Quaternion.Euler(0f, angle, 0f).eulerAngles;
``````