# unity rts on mobile : how can units find each other as simple as possible

Situation:

• I have a grid of 100 by 100 tiles.
• each tile has a list of units that are currently standing ontop of it.
• in this grid 500 units of team 1 and 500 units of team 2 are randomly walking around.
• while they are walking around they place themselves in the unitlist of each tile they are on.

problem: Each unit has to check lets say a square of 6 by 6 tiles around the tile he is on, to check if there is an enemy nearby.

my solution. each unit checks on top of what tile he is and only when it changes tiles it will check the 36 tiles around its current tile and check all their unitlist to check for nearby enemies...

Question.

1. isn't there a better way to do this? Because when I need my units to have a bigger line of sight of lets say 15tiles it needs to check 1000units * 15tiles *15tiles = a gazillion...
2. Does there exist a very inexpensive way of using somekind of a basic circle collider in unity without the need for rigid bodies etc...?
• Silly question: Does it matter whether a tile has 1 or 1000 enemy units? Because if not, then you can create a model of the map that contains a list of players in each tile and then check against that. So, no matter how many units of player 1 are in a tile, it's still only player 1 in the new map model.
– pek
Commented Mar 27, 2014 at 0:59