Search Unity

Making Modular Levels - Snapping Pieces Together

Discussion in 'World Building' started by EternalAmbiguity, Jun 15, 2018.

  1. EternalAmbiguity

    EternalAmbiguity

    Joined:
    Dec 27, 2014
    Posts:
    3,144
    Just curious if there's any info out there for making modular levels with probuilder. I imagine a scenario where a level has four total sections, but it goes 1-2-1, splitting there in the middle like so:

    ........._____
    ____/..........\____
    ........\_____/

    (the forum won't let me keep that structure unless I have text in the blank spaces--ignore the periods)

    The split might be vertical or horizontal, but either way I imagine I'd need to do something like:

    -Create a level "section"
    -Create a "start section" template
    -Create an "end section" template
    -Create a "diverge sections" template
    -Create a "converge sections" template
    -Figure out how to make these things snap to each other in the editor (I'd need to make the diverging section snap to an "end" section on its front end, and snap to "start" sections on its back end, and visa versa for the converging section).

    Does anyone have tips on ways to do the snapping of different sections (or meshes in dev speak) in the editor? Ultimately I want the levels to be procedurally generated, so the snapping needs to be able to happen at runtime (though for now a static solution would get me started).

    Along similar lines, is it possible to create a "section template" that contains multiple sub-objects? I want to be able to make a section with things like a trigger to spawn enemies, or to populate the level with different types of thematic props at runtime (so a script to do that). Would simply a prefab work for this? Can I procedurally use prefabs in Probuilder?

    ...also, after generating the levels can I somehow make the props part of the level? I've heard of this, making props and a level all one mesh, but I don't know what the precise term is called or if it can be done in Probuilder (and without knowing the name I don't know how to search for it).
     
    Last edited: Jun 15, 2018
  2. gabrielw_unity

    gabrielw_unity

    Unity Technologies

    Joined:
    Feb 19, 2018
    Posts:
    963
    Hi! The first and most important thing, in my experience, would be to start very simple. Use simple blocked-out shapes, get a system that works, then start detailing.

    Using ProGrids will also help immensely :)

    The upcoming Nested Prefabs feature will be a big help!
     
    phobos2077 and EternalAmbiguity like this.
  3. EternalAmbiguity

    EternalAmbiguity

    Joined:
    Dec 27, 2014
    Posts:
    3,144
    I'm having an issue where my vertices all seem to be connected to my "origin" vertices, meaning my shapes are only based on the individual vertex-to-vertex differences if there isn't a more direct line from any given vertex to the origin vertex (or rather, it includes both).

    Unity_2018-06-16_12-39-19.png Unity_2018-06-16_12-43-44.png Unity_2018-06-16_12-45-42.png

    Any tips?
     
  4. gabrielw_unity

    gabrielw_unity

    Unity Technologies

    Joined:
    Feb 19, 2018
    Posts:
    963
    Ah, that looks like triangulation failing. Try this:

    1. Select the blacked-out face
    2. Delete it
    3. Select one of the now-open edges
    4. Click "Fill Hole"

    That should rebuild the face. However, it might not, and even if it does you'll still have a potentially troublesome n-gon. To avoid this, you can use "Bridge Edges" multiple times to build quads across the gaps, exactly as you want them. This will also help for smoothing if you need to raise/lower sections later on :)
     
  5. EternalAmbiguity

    EternalAmbiguity

    Joined:
    Dec 27, 2014
    Posts:
    3,144
    "Fill hole" worked. Many thanks.