How to find objects within an angle in the opposite direction from target.
I'm designing an AI for my game, however, I always struggle when it comes to angles. I'm in the process of having my AI retreat and take cover behind an object.
I figured the best way to do this would be: If the AI is facing the player - find the closest object (cover) opposite to the direction of the player and take cover. (In the diagram it would be object 3)
I would like to search for an object within a 120-degree radius behind my AI.
(I already have methods to find all objects, and insert their transforms into a list containing)
(All I need is to select an object if it is within the area opposite from my player character.)
Thanks!
Additional: Something I haven't dealt with yet is taking cover, is there an easy way to find the edges of an object and go behind it?