Original Post
Hi community, I am new here and start with a very tricky question. I am designing a strategy game (comparable to Warcraft 3 or stuff like that). I have two difficult functional requirements, which I want to handle with high performance: -Picking Units in Range: For Splash damage attacks (explosions, spells, ...) I want to be able to pick all units in Range of a specific point. Since there may be many units on the battlefield the naive approach of just looping over all units and testing is not possible, of course -Aura effects: Units should be able to have effects comparable to Warcraft's Auras: I.e. Whenever a unit comes into a specific range of a unit having an aura, an effect is applied to it. For example the movementspeed of all enemies in XXX Range of a unit could be slowed to 50% with such an aura. But how to efficiently check when a unit comes in range of an aura giving unit? I cannot check every unit against every aura every frame. The game is 2D, at least these two effects can work on a 2D landscape (even if the landscape might get 3D). Here is my approach so far: The map on which the battle is done is divided into a uniform grid. Whenever a unit moves to another cell of the grid, it is registered there. I build a quadtree on this grid. I use this quadtree for the "Picking units in Range" task by going down from the root only if one quad is in the desired bounding rectangle of the pick and is not empty (i.e. contains units). Is this approach good for picking units in range or is there a better one? And now to the aura effects: I really have no clue at the moment how to manage such an effect with high performance. I also haven't found any information about this on google. However, Warcraft 3 seems to handle it very performant. Even with hundrets of units and many different auras, the game is still not losing any framerate. I think the core feature that would allow me auras is to detect when a unit comes into a specific range of an aura unit. But how to do that with high performance? Can someone help me here? (Sorry for my bad english, if something is unclear, just ask, I will try to explain that part better then)