AI that attacks only from behind

Yeah, you just need to check if the bool is true or not. No need to do viewport stuff. If the bool is true, then the AI Character is on the players screen. The ScreenPosition can be used to tell exactly where the Pawn is on the screen. It is scaled to the resolution. If your resolution is 1920x1080, then the ScreenPosition will have values from (0,0) to (1920, 1080) depending on where the AI character is on the screen.

Also one thing to note, it for characters GetActorLocation gives the location at the bottom of the capsule, most likely the feet of the character, you probably want ot check against the eyes or something.