I’m working on a small game that has a basic hero and enemies. The hero shoots the enemies when they get within a certain range of him. As of now I have looping through the enemies, getting the distance between them and the hero to determine if they are close enough for the hero to attack.
However, adding more heroes makes this method seem… ineffective. I have to loop through all the enemies for each hero I have. It seems like a waste to run calculation on enemies that are nowhere near the hero.
Is there another (better) way to go about doing this? Maybe making a invisible circle around the radius of the hero and using hittest to see if anyone is in range?