Indicate Objects behind User

Hello, I’m doing a project where the user has several boxes in front and several behind him and everytime one box was found another one gets randomly selected.
To find the next box I use an arrow that points in the direction of the next Box and a line drawn from the arrow to the box.
I already tried the DirectionIndicator and HeadsUpDirectionDirectionIndicator scripts from HoloToolkit and some own ideas.
The problem is that, if the box is behind the user, the arrow and line are turned upwards although the user has to turn left/right to find the box behind.
Anyone knows what I could change in the code or use instead to make the arrow and line turn left/right instead of upwards if a GameObject is behind the user?
Below you can see some pictures to better understand what I mean.

Box in front of user


Box behind user (current state)

Box behind user (how i want it)

Depending on how precise you want it (entire box behind user versus just its center), this could be solved with a dot product. Just dot the user’s forward vector with the vector from the user to the box, potentially zeroing out the y component on both vectors since it seems you might only care about the x-z plane - if the result is less than zero, it’s behind the user.