Directional blocking like in Dark Souls.

I can’t figure out how to compare directions between attacks and player’s block. I have the direction the attack is going in, the direction the player is blocking towards and if the player is blocking but i’m not sure what i need to compare these values. I’d like the player to block relative to their block direction -90 and 90 to either side of y direction.

attackdirection = transform.eulerAngles.y-180;
blockdirection = player.transform.eulerAngles.y; 
if (attackdirection >= blockdirection-90 && attackdirection <= blockdirection+90) block = 1;

This code is in OnTriggerStay for attack. The code would look similar to that but there might be issues with overflowing which i’m not sure how to fix. There might even be things built into Unity that i could use that i’m not aware of.

Why not use a trigger where the shield is? And then simply negating the attack if said attack hits the shield. Granted you also use a trigger to determine the attack hitting.