I've been puzzled for a few days trying to solve this problem, so far with no results.

On a map, currently a Terrain, I'd need to have some "areas" which can be controlled by a specific players. The shape of those areas can arbitrarily change during the course of the game, such as you add a marker in any point, and the area evolves (like a spline, say) to pass through that point too.

The problem isn't drawing the boundary itself, of course, but having the GameObjects detecting the area they are in.

Currently I have absolutely zero idea on how to make this exactly.

I've thought about a nice approximation, which is splitting the terrain in fixed chunks, and having the player control them "chunk by chunk": every chunk can have its own collider, and that should be easy if not trivial. So the question is how to do it "properly", since I already have this workaround.

  • 1
    \$\begingroup\$ I would create a polygon from the points, do a is-point-in-polygon check. Would that work for you? \$\endgroup\$
    – Felsir
    Jul 24, 2015 at 13:28
  • \$\begingroup\$ @Felsir you mean, without using Unity components and functions like Colliders, instead having a custom-made function to do the check? That's brilliant and obvious, silly me! Could you post it as an answer, if that's really what you meant? \$\endgroup\$
    – o0'.
    Jul 24, 2015 at 13:43
  • \$\begingroup\$ That is exactly what I meant :-) \$\endgroup\$
    – Felsir
    Jul 24, 2015 at 14:05

3 Answers 3


I suggest this approach.

Use voronoi 2d subdivision for your space (in the example the central points distr is (pseudo)random, but you can insert your logic)

enter image description here

Then asociate a value to each point that results (in the example image) in different color for each cell

enter image description here

You can play with the number of point and/or distribution to get more defined shapes. For the voronoi diagram property, when you click on the map , the origin point nearest to your click position identifies the voronoi cell you are in.

  • \$\begingroup\$ But isn't this basically equivalent to my workaround "divide it into chunks"? \$\endgroup\$
    – o0'.
    Jul 24, 2015 at 14:03
  • \$\begingroup\$ you overcome Unity colliders \$\endgroup\$ Jul 24, 2015 at 14:37

Create a polygon from the points, do a "is-point-in-polygon" check. So whenever the players add a point that would expand the "area" regenerate the polygon. On the update do a simple position check against that polygon to determine if an object or player is inside the area or not.


I solved this problem using an hybrid approach, inspired by:

  • my original workaround
  • @Felsir's post
  • @dnkdrone.vs.drones's post


I have Chunks, which may have an owner or be contested.

  • Inside a contested Chunk, different players have their areas of influence.
  • Instead of using a definite polygon/line border, inside the Chunk itself every player may place Flags.
  • The Chunk itself is dividend into equally distanced ChunkPoints.
  • A ChunkPoint's owner is the nearest Flag's owner.
  • Chunk's % ownership is how many ChunkPoints you own.

first screenshot screenshot with sub-areas


Using a polygon approach turned out to be too complex because I had to detect the order of the points, and they could with time take very complex shapes, which wasn't obvious how to handle.

I considered using voronoi's before realising that a ChunkPoint map was much easier and equally good for what I needed to do (but trying to use them was the source of inspiration that got me there).

In the original workaround idea, Chunks weren't "contested", they were just fully-owned by a single player, and that's why I didn't like them.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .