Effecient finding of long-range spotting targets
- by nihohit
I'm creating a top-down 2d strategy game, with a square grid map.
So far, I've used Bresenham's line drawing algorithm in a circle to determine what's in LOS of each unit, and then targedt one of the targets in the circle.
Now I find that this limits my units to shoot only at targets that they see. I want to extend my targeting algorithm to target any other unit in range of my weapon, even if they're out of sight range of this given unit, if they're "spotted" by another friendly unit. In other words, I want to enable usage of weapons with ranges longer than sight range.
Is there a better way than iterating over all sighted units and computing range and LOSto each of them?