One route you could go down (and perhaps the simplest) would be to read up on UAIPerceptionComponent.
However, for a more complex, customized answer…
Sounds like you need to utilize some sort of camera frustum system, instead of just a single float variable.
Here’s a more technical walkthrough:
Send raycasts out from the left and right sides of the view’s frustrum, testing if the target (or a portion of the target) is within these boundaries. Then, you could also do the same for the top & bottom sides of the view. If nothing was hit, then nothing is to be done. However, if a character WAS hit…
To discover how far away from each side of the view frustrum the target character is, it’s a simple matter of perspective projection (to convert the 3D points into 2D), and then dividing these points along the X & Y planes to get scalar values, which would represent a percentage from the center.
EDIT:
I just realized, you actually want to find how much of a player can be seen even when fully centered in view, but with obstacle(s) in the way. So much like the above example, you would still do some raycasting to test for hits, but you would need to test against some arbitrary number of hits to determine if a “threshold” has been reached or not.
So read up on Raycasting, and do some tests for when the player is fully in view and close up, fully in view and far away, partially in view and close up, and then partially in view and far away. Print out the number of hits for each scenario, and then decide on some middle ground.
If you wanted to obtain a bit of extra AI, you could even add a “suspicion level” which gets raised based on the number of successful raycasts to a target player, which could help determine exactly “how interested” or compelled an enemy would actually be to investigate their suspicions in the first place. You could then add this to your float value to determine how crazy the AI should be. This would also allow your AI to detect when it has been surprise-attacked, just for example.