Search Unity

Modular corridors, rooms... where to begin?

Discussion in 'General Discussion' started by SingularityDivision, May 30, 2016.

  1. SingularityDivision

    SingularityDivision

    Joined:
    May 9, 2016
    Posts:
    23
    I want to do this right.

    I am considering what is needed to make a game with a level structure similar to Ziggurat, or any number of randomly generated dungeon games. The thing I am focused on now is not so much "can it be done" or "how do I program this"... the issue for me, is that it needs to be 3D and it needs to look decent. Not friggin' amazing. Just, not like total butt.

    Examples of what I mean by modular corridors and rooms:

    maxresdefault.jpg dark cloud.jpg

    I'm not concerned with how to piece together these structures, in terms of coding and layout and generation, that I am certain I can figure out. My main questions are...

    1) Is there a good tutorial, resource, or something that I can use to educate myself on how to construct interior 3D models properly so they work well in games?
    2) I am concerned with graphical issues where hallways and rooms meet, where two sets of geometry meet, as I don't want to bother with creating a seamless 3D environment. I have some ideas as far as using doorways to completely hide the seams. I am just wondering if there aren't some edge cases I haven't yet considered that I need to consider?

    I don't mind doing the work, but I'm looking for a little guidance out of the gate. My experience with 3D is really limited and I don't want to self-teach myself everything, I would just like to use some proven methods that work.

    Thanks.

    Edit: I'm glad I asked, specifically that Skyrim modular post almost reads like an instruction manual for creating modular maps, this is going to be fun.
     
    Last edited: May 30, 2016
  2. KnightsHouseGames

    KnightsHouseGames

    Joined:
    Jun 25, 2015
    Posts:
    850
    Oh my god, Phantasy Star Online and Dark Cloud! I loved both of those games.

    The generating piece is probably harder than the models

    The way I'd start is just with square rooms. The only thing you need to know about interior 3D models is making sure your faces face the right way. Unity uses Backface Culling, which means it only draws the texture on one side of the face, making the other side effectively see through. If you get this backwards (like I have in the past) all of your interior walls will be invisible, and you won't be able to see into your room because all the outside faces will be visible. I forget what the command is called, but you can flip which side is the front on models if you need to to make sure you can see through the walls on the correct side. Other than that, just make prefabs of each room and have a map generating class use those prefabs.

    As far as connecting nodes, perhaps you want to give your node class knowledge of how many doors it has and which way they face, and have it choose a model with the corisponding amount of doors, and rotate it to fit the orientation of those doors.
     
  3. Rombie

    Rombie

    Joined:
    Feb 18, 2015
    Posts:
    282
    Well Modular building is actually kinda simple. It's just making sure everything fits perfect like a puzzle.

    The most important thing for a modular system that works is building in a grid. If you are using Unity; use meters.

    If you build everything so if aligns within the grid you shouldn't have issues with corridors meeting doorways, and final product should be seamless. Just make sure everything is contained within the grid boundaries and you should be good.
     
  4. SingularityDivision

    SingularityDivision

    Joined:
    May 9, 2016
    Posts:
    23
    Seems like you've thought of this before. It's not much different than a 2D tile engine the supports shapes, like this



    Where you can code the engine to figure out the corners on its own, all you do is place "grass tile" or "dirt tile" and the rest just takes a pass from the engine, looking at neighboring tiles, to figure out where to put the corners.

    Only here, rooms will have openings that can become doorways, hallways connect the rooms and everything is basically on a sort of grid system. I started with 2D tile engines, originally so it doesn't seem too tricky to me.
     
  5. SingularityDivision

    SingularityDivision

    Joined:
    May 9, 2016
    Posts:
    23
    I am going to use Blender for the modeling, is there any special tips in terms of how to set up textures or what scale to make things in Blender? I can't imagine it being as simple as described, but that sure would be a nice break if it was.
     
  6. Ryiah

    Ryiah

    Joined:
    Oct 11, 2012
    Posts:
    21,190
    Are you referring to Daggerfall by any chance? :p



    Usually I link the following article to people asking about modular level design. It was written by the lead level designer for Bethesda. I believe it covers at least part of what you're asking for. If not then it's at least very interesting.

    http://blog.joelburgess.com/2013/04/skyrims-modular-level-design-gdc-2013.html
     
    Last edited: May 30, 2016
    Ony and Billy4184 like this.
  7. KnightsHouseGames

    KnightsHouseGames

    Joined:
    Jun 25, 2015
    Posts:
    850
    Yeah, I'm using a procedural generation system for one of my games right now, except instead of letting the system generate the map, I have it generate the map based on a CSV file, it's effectively 3D paint by numbers. I don't have to worry about doorways and stuff though, I'm just generating primitives.

    But clearly you seem to understand what I find to be the hard part.

    I'm trained in Maya, so I don't anything about Blender. But I'd say to get started, take a cube about the size of the rooms you want, and use whatever command Blender has that is most similar to Flip Normals. If the cube disappears, zoom into it and you should have an enclosed cube that you can turn into the basis for your different rooms. From there, you should be able to follow some tutorials for basic modeling in Blender to do the rest.
     
    SingularityDivision likes this.
  8. SingularityDivision

    SingularityDivision

    Joined:
    May 9, 2016
    Posts:
    23
    Well, visualizing the grid is a good start, but a bit counter intuitive if you're new to CS. You can find tons of info by searching for "traversing arrays". Good luck!
     
  9. Billy4184

    Billy4184

    Joined:
    Jul 7, 2014
    Posts:
    6,023
    The Skyrim link is good as well as this one which is maybe a bit more concise:
    http://www.thiagoklafke.com/modularenvironments.html

    In the end, just make stuff and get used to how it feels. The main thing is to simply make sure it all fits cleanly into a grid, and that the pivots are on the corners.
     
    neginfinity and Ryiah like this.
  10. SingularityDivision

    SingularityDivision

    Joined:
    May 9, 2016
    Posts:
    23
    To be fair, this probably looked great for the time... but yeah, I don't think people would respond well to this these days.
     
  11. KnightsHouseGames

    KnightsHouseGames

    Joined:
    Jun 25, 2015
    Posts:
    850
    Oh no, it's not a question of understanding I get it, my game works, I even have AI that can traverse the grid

    I just mean out of the two tasks at hand, the easier one is making rooms. If you find programming a giant 2d linked list easy, then you've already conquered the hardest step, and it's on to the fun part from there.
     
    SingularityDivision likes this.
  12. Ryiah

    Ryiah

    Joined:
    Oct 11, 2012
    Posts:
    21,190
    By the way the engine for Daggerfall is being remade in Unity if you wanted to see the code in action.

    http://www.dfworkshop.net/projects/daggerfall-unity/
     
    NotTesla likes this.
  13. SingularityDivision

    SingularityDivision

    Joined:
    May 9, 2016
    Posts:
    23
    Haha, that's interesting... it just comes down to comfort zones. I'll be you've spent more time modeling than I have, to me it always seems daunting... like it's never going to turn out. Even if I approach a very difficult coding task, I always know that I will figure it out, eventually.
     
  14. tiggus

    tiggus

    Joined:
    Sep 2, 2010
    Posts:
    1,240
    My experience with 3d is fairly limited but one thing I noticed when I built a modular system was that the wall sections were quite obvious due to lighting treating them as individual objects instead of a single long corridor. Ie. you could see the light go from bright on one edge to darker on the other, then it would repeat like that on the next wall section.

    Maybe I was doing something really noobish(sure I was) but curious if that is a common problem with modular building.
     
    SingularityDivision likes this.
  15. SingularityDivision

    SingularityDivision

    Joined:
    May 9, 2016
    Posts:
    23
    Never played this game before. It looks an awful lot like Elder Scrolls.

    Even though it's really low-rez, it looks alright. Something about crawling around dungeons and getting attacked by everything draws me in. Such a rush.
     
    Last edited: May 30, 2016
  16. SingularityDivision

    SingularityDivision

    Joined:
    May 9, 2016
    Posts:
    23
    I second this question... is this something that will happen?
     
  17. neginfinity

    neginfinity

    Joined:
    Jan 27, 2013
    Posts:
    13,571
    It IS elder scrolls. Elder Scrolls II: Daggerfall.
     
    Kiwasi and SingularityDivision like this.
  18. SingularityDivision

    SingularityDivision

    Joined:
    May 9, 2016
    Posts:
    23
    Hahaha... I had literally no idea.
     
  19. neginfinity

    neginfinity

    Joined:
    Jan 27, 2013
    Posts:
    13,571
    Ah, you will hit issues with highly modular geometry.

    Issue number one - static baked lighting for modular environment doesn't work well. There will be seams. You won't be able to get rid of them.

    Issue number two - if you, say, throw fireball through the corridor made out of tiled floors, then while the fireball passes through the scene, it will reveal floor structure. Meaning individual tiles will be unevenly lit and will "light up" when point light crosses their boundaries (meaning at the moment when point light ceases being "important" for one tile and becomes "important" for another.)

    Those issues will be very hard to fix, if you're dealing with unity standard shader. However, if you, say, create a toon lighting shader or another-world-like geometry, you should be fine. It is possible that in deffered mode the issue will be less obvious.

    The funny thing is that making the whole level as one monolithic model is also a bad idea. Because if you're playing the game in forward-rendering mode, your whole mesh will be subject to limit on number of point lights per mesh. So new lights may not affect it.

    Either way, you'll need to find a way to deal with this during debugging phase once you have prototype ready. Make a prototype first.

    If you disable ambient lighting, reflections and make sure the lighting is not baked, then IIRC modular structure won't be very obvious. Having textures on pieces also helps.
     
    SingularityDivision likes this.
  20. tiggus

    tiggus

    Joined:
    Sep 2, 2010
    Posts:
    1,240
    I'd say fire up the editor and give it a shot with some textured cubes. It may have been related to a screen space area lighting plugin I was using.
     
  21. SingularityDivision

    SingularityDivision

    Joined:
    May 9, 2016
    Posts:
    23
    Oh boy, I never would have thought of this stuff. I'm glad you guys posted a link to this, we're talking about decades of hindsight here.
     
  22. KnightsHouseGames

    KnightsHouseGames

    Joined:
    Jun 25, 2015
    Posts:
    850
    But the thing with 3D modeling is it isn't as rigid as programming. With 3D modeling, there is no failure, it's like playing with clay, evenually you'll end up making somethng. I learned 3D modeling in like 1 semester in college, it took me like 4 semesters and a year worth of Youtube tutorials to reach my level of proficiency in programming, ha ha

    But yeah, you are probably right, it is probably just a comfort zone thing, I have a friend who I always say has a mind of metal and wheels, he can figure out any programming problem I throw at him no problem. But he just does not have a feel for 3D modeling or any kind of art really.

    Some people are just born artist and some people are just born programmers. I just happen to walk the line in the middle where I am passible at both, but not an expert at either I guess
     
    SingularityDivision likes this.
  23. SnowInChina

    SnowInChina

    Joined:
    Oct 9, 2012
    Posts:
    204
    for a modular aproach you best start of with a grid
    define standart values for height, width and lenght for different pieces so that your characters can properly interact with everything (like doors) and the scale doesnt look off
    then write down every single piece you will need, you can extend this later on (and most likely you will have to)
    use placeholder pieces which you can later on substitute with the final art

    if setup correctly you should be able to build levels pretty quick, like putting together lego
    keep in mind that you will most likely need some individual pieces to close gaps, especially if your level does not follow 90° turns on every corner

    the better your planning phase (and your grid system) the less hassle you will have later on
     
  24. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    Search for roguelike generation, there's several, including even a unity tutorial for procedural cave generation. Once you have your stuff on the grid, the rest is easy.
     
    Kiwasi, Ryiah and Martin_H like this.
  25. Ryiah

    Ryiah

    Joined:
    Oct 11, 2012
    Posts:
    21,190
    That's because it's an Elder Scrolls game. The Elder Scrolls II: Daggerfall. It has one of the largest procedurally generated game worlds at over 160,000 square kilometers. If I recall you can cross the map in about a couple of weeks real time. :p
     
    Last edited: May 31, 2016
    Kiwasi and Martin_H like this.