Change color depending on land capture

I am wondering how would I be able to implement a system where when you capture a city it changes the color of the land like Rise of Nations.

We cant have multiple parts as the game needs to be optimised and the parts will overlap causing it to look glitchy, we think that the solution is something got to do with unions but we don’t know how we would go about implementing it.

So there could be many ways to approach this depending on your game mechanics and use-case. Assuming there is one city per “territory” of surrounding land you would be looking to call a function to change the color of the land to the color of the team that captured it whenever there is a change in control over the city.

If you have a map (or even a set of different maps) that are always the same, then yes you could use Unions. You would have to create the unions in the shape of the territory surrounding each city manually though. You can change the color of a Union the same way you would change the color of a Part (but make sure the UsePartColor of the Union is set to true).

The approach gets more complicated if you are generating maps randomly since you will have to construct the territories surrounding the cities each time a new map is generated (changing the color of the territories shouldnt be too different from the method used for predefined maps though). This could be done many ways such as simpler algorithms using static cells (triangular, square, hexagonal) or more complex algorithms using voronoi diagrams either along or combined with noisy edges between territories.

It’s the same map of the earth but I am wondering what is the easiest way with the smallest amount of lag to this, we already considered having a union per city and it won’t work as we have multiple cities per country.

We thought about scripting it so it splits the union whenever land gets taken over and recolors it but we don’t know how we would use this or if it is even possible this way.

You likely wouldn’t want to split Unions at runtime as this can have an impact on performance. If you already have a union for each city, I’m not sure what issue you’re having. Maybe I don’t understand the effect you’re going for. Would you not just change the color of the union associated with each city whenever it’s captured?

I don’t have unions for each city I just have parts displaying where the city should be with a billboard gui.

I think we found out a way to do it anyways, thanks for the help though.