Check GameObject rotation in Y axis when OnTriggerEnter

Hi,

I’m trying to do “ActionA” when GameObject “B” rotation in the Y axis is 180 or -180 and enters a Trigger but it not working. My script is the following one:

void OnTriggerEnter (Collider other) {
	if (GameObject.Find ("B").transform.rotation.eulerAngles.y == 180.0f) {
		doActionA;
	}
}

Because of floating imprecision, you should not compare the values with the == operator but with the Mathf.Approximately function for example

void OnTriggerEnter (Collider other)
{
     Vector3 angles = GameObject.Find("B").transform.rotation.eulerAngles ;
     Debug.Log( angles.y ) ;
     if (Mathf.Approximately(angles.y, 180) || Mathf.Approximately(angles.y, -180) )
     {
         // doActionA;
     }
 }