I have several targets named as Target1, Target2, Target3, ..., Target8 (these targets are static) however enemy's position changes on every shot, randomly. I would like to calculate the angle between the enemy and the targets to determine which one can be shot at without hitting the obstacles. However depending on the enemy's position, which is random, I wish he could choose priority targets. Targets have priority within each other, i.e., Target1 have priority over Target2 which has priority over the target3 and so on.
I'm not using LOS cause even if the enemy has line of site of the target, sometimes the bullet could not pass between the obstacles, hitting them most of the times. (His bullet is much larger than the LOS and there is just small gaps between some obstacles).
My questions are:
1) How may i set the Target priority? - (nearest/furthest isn't doing the job, cause the priority targets are not always near or far, as enemy's position changes)
2) Is it possible to create a variable, to change selected Target ? What I imagine, but can not do, at least with my little knowledge is: angle (enemy.X, enemy.Y, Target (T) .X, Target (T) .Y)
In this case, assuming that it is not possible for the enemy to hit the Target1 I would simply add (T + 1) to calculate the angle between the Target2, and so on.
I know this is a lot of work, maybe too advanced for a newbie like me, but if you may have some ideas, it will be great!