Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

How to make field painter like cities skylines districts?

Discussion in 'Scripting' started by Shoopen, Jan 16, 2016.

  1. Shoopen

    Shoopen

    Joined:
    Mar 14, 2015
    Posts:
    7
    Hello!
    I asked simillar question here http://answers.unity3d.com/questions/1128026/how-to-make-field-painter-like-cities-skylines-dis.html
    but I'm writing here because I think there is less traffic, so the question won't just disappear.

    Can you explain me how to achieve such an effect as did the developers of Cities Skylines in feature called districts?

    I mean... How to draw those fields with boundaries updated at runtime, edit it and substract by creating other near it.

    I know they were using Unity to make this game, so i it has to be possible to achive, but i have no idea how - I don't even know how to draw a polygon.

    I know this topic - I learned a way explaining it a little bit, but I still don't know how to start.
    http://answers.unity3d.com/questions/938945/how-does-the-districts-painting-work-in-cities-sky.html

    So i broke the problem into smaller segments (which are my questions):
    1. I need to know how to draw a (round) polygon at runtime.

    2. I need to know how to use knowledge from here in practice and combine the new polygon with older one. https://en.wikipedia.org/wiki/Boolean_operations_on_polygons

    3. I need to know how to animate the boundaries.



    How about the navigation system in unity and baked ground with non static objects moving around? You can move this object and the Navmesh is updating quickly. How is that done?

    And i think it's all. Any answers and comments are appreciated. Thanks in advance!
     
  2. kru

    kru

    Joined:
    Jan 19, 2013
    Posts:
    452
    I think the Cities Skylines guys used the Marching Squares algorithm to build their specific visualization texture of the district. Then they project the texture on to the ground. Since the ground in their game is flat, with no overlaps or interesting geometry, this provides a good, fast visualization. One could probably get away with just painting directly to a texture and making it pretty.

    Check out Vertex Painting. It's a somewhat advanced topic to implement from scratch. However, there are assets on the asset store that can get you started.
     
    domkia likes this.
  3. Shoopen

    Shoopen

    Joined:
    Mar 14, 2015
    Posts:
    7
    Hi! Thanks for the reply.
    I've read about the Marching Squares and i think it's not it - I mean by using this algorithm game must have something like grid to snap each points. Of course - Cities Skylines has a grid but only in zoning (snaping to the roads). By using grid in painting districts boundaries would jump and snap each point, but in the game it is smooth. I made a video to show what i mean. Painting zones is not smooth (snaping to the grid), painting districts is smooth (It's what i'm looking for). It's like moving points and adding couple new.
     
  4. Fishmastr

    Fishmastr

    Joined:
    May 28, 2019
    Posts:
    1
    Hi folks,
    i know this is necro posting, but i require exactly the same feature and i didn't found a clue pointing me in a direction that could work. Would be nice if somebody could drop at least some buzz words to help me out and save me hours of time searching for the right terminology.

    is this called "field painting"? my idea is i could make a plane of objects and "paint" them with a sphere collider, but in my eyes this is very uncomfortable and inefficient, so i hope you guys have something at hand for me.

    Thanks in advance!
    Fishy