Announcement

Collapse
No announcement yet.

Newbie tries making a fantasy city generator

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Newbie tries making a fantasy city generator

    I'm an artist and an Unreal-newb currently trying to come to grips with Blueprints and the wonderful world they offer. I'm not used to actually making stuff DO something except trying to make it look good, so this is incredibly fascinating to me. I'm also completely out of my depth, but relishing the opportunity to learn.

    Long story short: I want to make a fantasy city generator, as a part of an even greater RPG scheme far out on the horizon. So far, I've reverse-engineering and stuffed my own meshed into the procedural flowerbed found in the Blueprints example project, since I couldn't even begin to put something like that together from scratch just yet. That's left me with seed-based, random cities that can be modified to whatever size and density I want, and which auto-conforms to the ground below it. It even looks kind of decent, if still a bit sparse and samey:



    As a first test bed, this is lovely and I'm quite proud, but it's pretty far from being usable for anything since it's just spawning everything randomly without any system behind it. And it's quickly becoming apparent to me that I could use some guidance if I want to take this to the next level.

    So, I wanna begin a more ambitious Version 2, on which I'd welcome any input or links to relevant tutorials:
    - First and foremost, I wanna randomly generate the buildings somehow. I can build the parts, no sweat, but actually making the system for putting them together is still a mystery to me. Optimally I want some kind of snapping node-based system with interchangeable parts, so I could exchange window types and roofs and all that randomly from a set pool of meshes.
    - Then there's the whole business of actually getting roads in there, and having the buildings actually line up to those roads. Judging from what I've seen out there, that stuff is harrrrrrd (but oh so cool).
    - Buttressed city walls that auto-conform to the shape of the city would also be really neat. I'm *thinking* the terrain editor's spline tool looks like the right tool for the job, but I haven't really tried it out yet. And how to hook that thing into a blueprint, well, that's a whole other can of worms.
    - City quarters and plazas would go a long way towards making it look more like a city also - I'm thinking a sort of mini-biomes setup, with richer quarters and palace spawning sort of in the center, with gradually poorer quarters towards the edges.

    I'll come up with more stuff no doubt, and it's really just a fun learning exercise for me. But if you happen to have any input, I'd really like to hear it.
    Last edited by Bluntie; 01-28-2016, 06:00 PM.

  • #2
    so , you are triying to do something similar to city architect

    https://forums.unrealengine.com/show...city+architect

    Comment


    • #3
      So far it looks really good, even if it is just random placement with no order.

      You should build a Road Generator first though, once you get good looking road gen then you use your roads to define what and where your buildings will Spawn. Trying to spawn buildings then roads is the wrong way to go IMO.

      Good luck though!
      Marketplace Packages

      UnrealSlackers is a Community driven group of likeminded people here to discuss UE4! Join UnrealSlackers on Discord!

      Comment


      • #4
        @diegor: Ooh, good find! You're not wrong, from the looks of it - shall have to look more into this one.
        @DevilsD: Thanks! Yeah, you're probably right, I've no doubt I am going about all of this in a quite impractical way. One step at a time, very new to blueprints yet.

        Comment


        • #5
          So, I've gotten some way in now and managed to get a procedural building generator going, so I can get more building variation in there. I have two seperate blueprints - one just for making the procedural builings, and another that scatters them around, with the procedural building blueprint nested within. However, it is messing up my auto-conform-to-ground - I can't get the buildings to stop using themselves as colliders, so I get new buildings spawning on top of others. Is there any way I can make a blueprint sort of "ignore itself" when it comes to collision, since I do want the buildings to have colliders? Or can you come up with a smarter way than I am using?


          While almost kind of cool, it's not quite what I had in mind. :P
          Last edited by Bluntie; 01-31-2016, 06:24 PM.

          Comment


          • #6
            It looks like your tower has support cables in place holding it up...haha

            As for the collision you can go and create a custom collision channel in your project settings. Then when you setup collision tell it to ignore the collision of that type.

            Comment


            • #7
              Fantastic, thanks! Shall give it a go tonight.

              Comment


              • #8
                There is something very intruiging about the skyhigh building stacking
                Looks like you are on a good track Bluntie, keep it up!
                Twitter: ItsConnorReid

                Blueprint Tutorial | Basic Sprint - Beginner Friendly | Forum | Wiki
                Blueprint Tutorial | Stamina Decay/Regeneration Implementation | Forum
                Blueprint Tutorial | Stamina/Progress Bar Implementation | Forum

                Comment


                • #9
                  I am also very new to blueprints and have been tinkering around with a very early prototype of a pawn class that spawns individual robot part actors based on a list of parts i predefined (and will eventually link to a "garage" user interface).

                  While im not entirely sure its applicable, ive found success and making an actor blueprint class for each specific robot part (arm, leg, etc) and spawing them to a variable "attachement point" in the main pawn class.

                  [Warning: free-flow brainstorming ahead]

                  How i see this being applicable to your case is to make classes for each category of each building type (tower, residence, plaza) so you have a class for spawning each individual building type. This way you can debug the logic more easily.

                  Next you make another blueprint class that contains the logic for spawning the buildings/roads. So this is the class that handles the seed values and some sort of logic that states "if my building is overlaping a road (or another building), find a different spot to spawn this building!" (You can use blocking/collision volumes that spawn along a spline similar to the procedural wall tutorial to handle this).

                  As for the quarters, you can have the main city spawning volume blueprint class generate procedurally placed "sub-volumes" that pull from one of several arrays that seeds the individual building constructor above to spawn a building that corresponds to the theme for the quarter you want to generate. This is an easier approach but less "organic".

                  A more organic way to generate the procedural placement of "rich" core gradually becoming "poor" exterior, would be to have your spawning volume be just a central point (that spawns your plaza/townhall/castle) with the volume bounds being procedurally generated frm your seed (say, a procedurally generated "distance from the center cut-off" for each of the cardinal directions?). You can then have the "building type variable" (maybe an integer with 1 = "rich" and say 4 = "poor") be driven by a lerp (with a modulo operator so the float fits into an int?) Based on distance from the center? This would make it very uniform and "concentric" though, so maybe feed an addtional multiplier to make the boundary between quarters "fuzzier"?

                  As for why your building spawns on top of each other, youd need to give us more details on how your algorithm works.

                  Good luck on your efforts though! And if you need another newb with a lot of wild ideas to help you out on your project feel free to shoot me a message
                  Need another dev on your UE4 project? Send me a shoutout and I'll lend a hand

                  Comment


                  • #10
                    @ConnorTheScot: Hahah, you're not wrong. It's pretty close to being cool in some weird way.
                    @6ixpool: Some really good ideas in there, and very appreciated! I'm still getting to grips with how to think about stuff like this at all, so your ideas are very helpful. Thanks alot for the inspiration and for the offer of further help! This is all very much just a learning experience for me just yet, but it's not completely unthinkable that it might become something more if I can spark my bosses' interest - but that won't be for a long time, if at all.

                    Comment


                    • #11
                      @Bluntie - sorry i cant be clearer with how the logic operates. You seem quite adept with blueprints though seeing as how you managed to pull a basic city generator off despite your inexperience. Maybe my rambling will help nudge you towards the breakthrough you need.

                      Like i said though, I'm also very new to this all. If you want to collaborate on taking this to a step further, I'd be glad to lend my assistance, and be grateful for the learning opportunity

                      (and it really shouldn't take too long if we sit down for a few days to chrun out a useable/presentable prototype)
                      Need another dev on your UE4 project? Send me a shoutout and I'll lend a hand

                      Comment


                      • #12
                        @6ixpool: No worries, man! You already set a lot of ideas off, and figuring stuff out is fun. I have to turn you down on the collaboration for now though - I really want to make and figure out this thing myself, ain't nothing personal. Feel extremely free to make your own version if you want though, I'd love to see how someone else might tackle this kind of task.

                        Now, for the Question of the Day, for whoever might have an answer:
                        I'm trying to spawn additional floors in my buildings, using a ForLoop a randomized amount of times, but I can't figure out how to increment the position of each floor properly inside said ForLoop - they all move to the exact same position, and I'd really like them to spawn on top of each other, in a stack. It *feels* like I am missing something trivial here, but I can't seem to crack it. Like, what I'd ideally want is some kind of node that lets me increment the position *per* loop. So, like, first floor gets moved 300, next one is moved 300+300, third is moved 300+300+300...you know?

                        Comment


                        • #13
                          Actually, never mind! I just had a breaktrough. I put the desired increment in a Float, then added it to itself per loop with an Float+Float. It's not quite correct yet, but I can feel it's the right direction.

                          Comment


                          • #14
                            Youre on tye riggt track i feel. Try and store a variable called like "currentFloorZ" within the loop body with an operation like "currentFloorZ += floorHeight" (with "floorHeight" being a variable you can lookup thats inside the modular building actor).

                            If the floor heights are all uniform you can even just have it be like "floorHeight" * the current loop iteration (theres an integer pin you can pull out of the forLoop node for just that iirc).

                            Ideally you want to handle this by just manipulating the z vector by applying a "break vector" operation just so you dont inadverdantly move things around. (Although it could be just my paranoia talking)
                            Last edited by 6ixpool; 02-02-2016, 08:37 PM.
                            Need another dev on your UE4 project? Send me a shoutout and I'll lend a hand

                            Comment


                            • #15
                              Yep simplest way with that is just set an int for the "floor" which you increase per floor then times the floor height by the current floor. 300*1,300*2 etc

                              Comment

                              Working...
                              X