if( within 90 degrees of a certain degree of rotation)

How would i go about programming something like this? i have an object rotating around and empty and i want it to do something if its withing 90 degrees of 0 degrees and something completely different if its within 90 of 90 degrees does this make sense?

the setup is like this gameObject i am rotating around(A) has a child(B) my script is just using transform.rotate(A) based on mouse input.

sorry not great at explaining my situations hope it makes sense though. lol its late and my brain is slowly melting. just want to get this done and go to bed!

thanks in advance

I think the easiest way is to save the initial rotation, and use Quaternion.Angle to know the current angle - like this:

var rot0: Quaternion;

function Start(){
  rot0 = transform.rotation;
}

function Update(){
  var angle: float = Quaternion.Angle(transform.rotation, rot0);
  if (angle < 45){
    // object is between -45 and +45 degrees from the initial rotation
  }
}

Notice the weird 45 limit instead of 90: Quaternion.Angle (as well as Vector3.Angle) always returns a positive angle, no matter if to right or left (or up, or down etc.), thus you must accept half limit to both sides in order to check the full range.