Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Simple Building Kit - free package

Discussion in 'Made With Unity' started by MrSmive, Nov 29, 2010.

  1. MrSmive

    MrSmive

    Joined:
    Oct 12, 2010
    Posts:
    428
    So after looking at the Ultimate tank game thread i decided to make a simple building kit to improve the graphics of the games first level, this really isn't anything special its just 6 tillable models and 1 texture, compiled into an easy to use Unity package.

    To use just import the pack and start placing the building bases, then add as many floors as you want and then finally add a roof. Pretty good for making city type scenes seem less tiled and its relativly fast to set.

    Anywho here are some SS enjoy.



    Full Size - http://img530.imageshack.us/img530/1605/sb1s.jpg



    Full Size - http://img202.imageshack.us/img202/9906/sb2ur.jpg

    Here is the pack - http://www.mediafire.com/file/sptqq0o8hcgfcov/SimpleBuildingKit.unitypackage

    You can use this pack for whatever you want, just don't sell it as a pack or alone.
     
  2. superdave

    superdave

    Joined:
    Nov 7, 2010
    Posts:
    214
    thnx man
     
  3. MrSmive

    MrSmive

    Joined:
    Oct 12, 2010
    Posts:
    428
    np mate, if you put it in something, i would love to see how it turns out.
     
  4. pakfront

    pakfront

    Joined:
    Oct 6, 2010
    Posts:
    551
    nice, I was just looking for some basic buildings to put in a test project. These fit the bill.
     
  5. MrSmive

    MrSmive

    Joined:
    Oct 12, 2010
    Posts:
    428
    sweet glad i could help mate, love to see it when ya done
     
  6. mightymao

    mightymao

    Joined:
    Oct 21, 2009
    Posts:
    108
    Thanks!, I like free stuff!
     
  7. MetalHippy

    MetalHippy

    Joined:
    Nov 12, 2010
    Posts:
    5
    Cheers MrSmive much appreciated :)
     
  8. MrSmive

    MrSmive

    Joined:
    Oct 12, 2010
    Posts:
    428
    np gents, might make this pack a little bigger, didn't expect so many people would be in need of such a thing.
     
  9. Bren

    Bren

    Joined:
    Aug 28, 2008
    Posts:
    191
    MrSmive et al,

    I made a little SimpleCityKit that generates a "random city" from your building components. You can specify many parameters, i.e. the height of building, number of buildings per block (x y), number of blocks (x y) distance between buildings blocks, etc.

    Screenshot:



    Download package here:

    http://www.mediafire.com/?q0esgfiuuz58p43

    Drop me a message if you add any more building components, textures, etc. I will update SimpleCityKit!

    Comments/feedback welcome.
     
  10. Nikolay116

    Nikolay116

    Joined:
    Mar 21, 2010
    Posts:
    421
    that's flipping awesome!!!!!!!!!!!!!!!
     
  11. AndrewGrayGames

    AndrewGrayGames

    Joined:
    Nov 19, 2009
    Posts:
    3,821
    For a fun addendum for your city generator - add a random orientation for the roofs, at either 0, 90, 180, or 270-degrees. For that matter, add some alternate roofs of your own, and maybe some architectural doodads for sides that face streets, like balconies.

    Most awesome, though!
     
  12. StephenL

    StephenL

    Joined:
    Oct 18, 2010
    Posts:
    218
    Very nice work. :)
     
  13. Nikolay116

    Nikolay116

    Joined:
    Mar 21, 2010
    Posts:
    421
    I want to say I will contribute to the project with some models in december
     
  14. Bren

    Bren

    Joined:
    Aug 28, 2008
    Posts:
    191
    That's a good idea. I'll do the same for the bases, so the doors aren't always on the same side. Next update!
     
  15. Nikolay116

    Nikolay116

    Joined:
    Mar 21, 2010
    Posts:
    421
    Hey Bren,

    in short, I am trying to reuse your script on 2.6.1, the package imported well ,except prefabs and some otherstuff. My only problem is : what are "blocks" in the script? What they are for?

    Thanks
     
  16. Bren

    Bren

    Joined:
    Aug 28, 2008
    Posts:
    191
    There are two kinds of "blocks" -- maybe that should be cleared up.

    The one that is a prefab assigned to the SimpleCity script is the plane that is the ground, put under each "Block" and scaled to fit.

    The "Block" GameObjects are just empty GOs that are a parent for each block (i.e. the ground plane and some number of buildings).

    Does that answer?
     
  17. MrSmive

    MrSmive

    Joined:
    Oct 12, 2010
    Posts:
    428
    hey man thats freaking sick, ill wip you up a crap load more, these took very little time to make/
     
  18. mightymao

    mightymao

    Joined:
    Oct 21, 2009
    Posts:
    108
    Awesome! Greatly appreciated...
     
  19. BRIK

    BRIK

    Joined:
    Nov 27, 2010
    Posts:
    131
    Thanks man. Saved.
    Never know when you will need something like this.
     
  20. Bren

    Bren

    Joined:
    Aug 28, 2008
    Posts:
    191
    Hey gang,

    Updated the SimpleCity package:

    - Added random rotation to building bases and roofs
    - Made building pieces into prefabs so they could be set static
    - Gave city geom collisions
    - Added CombineChildren to each block (greatly improving performance!)
    - Made the Generate function a Coroutine so you can see the city being built
    - Spawn a simple FPS player in the centre of the city so you can walk around it
    - A few additional fixes and tweaks here and there
    - Re-org'ed the project a bit

    Screenshot:



    Package:

    http://www.mediafire.com/?eso8eba1s3f7lvw
     
  21. StephenL

    StephenL

    Joined:
    Oct 18, 2010
    Posts:
    218
    Very nice! I love the improvements! :D
     
  22. Nikolay116

    Nikolay116

    Joined:
    Mar 21, 2010
    Posts:
    421
    Hi Bren,

    thanks, I reworked your original script for my purposes, I also added rotations and scale
    In my project I will produce more building assets, and I will definitely share some with your project
     
  23. MrSmive

    MrSmive

    Joined:
    Oct 12, 2010
    Posts:
    428
    this is nice man you guys totally rolled with this one, i have some more stuff to do for another project but when i get the time ill make a few more, but things will get a little more interesting with more buildings, might have to work some chain commands into the random spawning.
     
  24. bradjensen68

    bradjensen68

    Joined:
    Feb 2, 2009
    Posts:
    274
    Thanks for this! I was playing around with it and wanted to try to use is with Cosmic Prophet's Building blocks (see http://www.thecosmicprophet.com or direct link:
    http://fps-media.mk-tek.com/downloads/packs/cosmicprophet/Building_Blocks/CP_Building_Blocks.rar) These are direct X but can be easily converted to FBX or just use the textures on a 5x5x1 cube.

    These are 5x5 in scale compared to the buildings here. I could figure out how to adjust for the size of the building. Could you give me some help? Thanks!
     
  25. blockimperium

    blockimperium

    Joined:
    Jan 21, 2008
    Posts:
    452
    The cosmicprophet stuff is pretty cool as well.
     
  26. MrSmive

    MrSmive

    Joined:
    Oct 12, 2010
    Posts:
    428
    Will probably be releasing a much better version of this in the near future, implementing a few different buildings with much better maps, so i would wait till then mate. This was more of a side thing for a game i saw on here that needed some better graphics, but as there is obviously a fair few people who could use something like this ill make a better one, probably release around new years time. Free of course, wanted to add some internal elements and other things so any ideas, ect let me know before i start.
     
  27. Bren

    Bren

    Joined:
    Aug 28, 2008
    Posts:
    191
    Nice work Nikolay116, looks like you're going for a race track type thing.

    bradjensen68, I *think* if you just increase the Block Span Building span 5x, it should work fine with your models.

    Adding streets is definitely the next step on my list of TODOs. I will make suer this gets in there for the next update. I've already chatted with MrSmive about moving this forward with some new models, textures, features, etc.

    How important do you guys feel it is to be able to a) design the layout of the city some way, and/or b) "save" a city layout into a prefab or something you can re-create or re-use?
     
  28. Nikolay116

    Nikolay116

    Joined:
    Mar 21, 2010
    Posts:
    421
    hey Bren, here is my script, check how I take care of scaling:

    Code (csharp):
    1. using UnityEngine;
    2. using System.Collections;
    3.  
    4. ////[ExecuteInEditMode]
    5. public class MyCity : MonoBehaviour {
    6.  
    7.     private float offsetY = -0.5f;
    8.     private float streetLength = 100.0f;
    9.    
    10.     private int maxFloors = 3;
    11.     private int minFloors = 1;
    12.    
    13.     private float streetWidth = 15.0f;
    14.     private float density = .7f;
    15.     private float mScale = 0.35f;
    16.    
    17.     private float[] angles;
    18.    
    19.   //  public Transform[] blocks;
    20.     public Transform[] bases;
    21.     public Transform[] floors;
    22.     public Transform[] roofs;
    23.    
    24.     private Vector3 mBaseDim = Vector3.zero;
    25.     private Vector3 mFloorDim = Vector3.zero;
    26.     private Vector3 mRoofDim = Vector3.zero;   
    27.    
    28.     GameObject cityRoot;
    29.    
    30.     int numBuildings = 0;  
    31.     // Use this for initialization
    32.     void Start () {
    33.        
    34.         angles = new float[4];
    35.         angles[0] = 0.0f;
    36.         angles[1] = 90.0f;
    37.         angles[2] = 180.0f;
    38.         angles[3] = 270.0f;
    39.                
    40.        
    41.         MeshRenderer MRB = bases[0].GetComponent<MeshRenderer>();
    42.         mBaseDim = MRB.bounds.size*mScale;
    43.                
    44.         MeshRenderer MRF = floors[0].GetComponent<MeshRenderer>();
    45.         mFloorDim = MRF.bounds.size*mScale;
    46.  
    47.         MeshRenderer MRR = roofs[0].GetComponent<MeshRenderer>();
    48.         mRoofDim = MRR.bounds.size*mScale;
    49.                
    50.         Debug.Log(mBaseDim);
    51.         Debug.Log(mFloorDim);
    52.         Debug.Log(mRoofDim);
    53.        
    54.         GenerateCity();
    55.     }
    56.    
    57.     void GenerateCity(){
    58.         /*
    59.         if (GameObject.FindWithTag("city"))
    60.            Destroy(GameObject.FindWithTag("city"));
    61.          
    62.         cityRoot = new GameObject("CityRoot");
    63.         cityRoot.tag = "city";
    64.         */
    65.        
    66.         int Ninner = (int)Mathf.Round((streetLength - streetWidth - mBaseDim.x)/mBaseDim.x*density);
    67.         float stepInner = (streetLength - streetWidth - mBaseDim.x)/Ninner;
    68.         int Nouter = (int)Mathf.Round((streetLength + streetWidth)/mBaseDim.x*density);
    69.         float stepOuter = (streetLength + streetWidth + mBaseDim.x)/Nouter;
    70.        
    71.         //place building
    72.         Vector3 tempPos = new Vector3(streetWidth/2+mBaseDim.x/2,offsetY,streetWidth/2+mBaseDim.z/2);
    73.         CreateBuilding(tempPos);
    74.  
    75.         tempPos = new Vector3(streetLength-streetWidth/2-mBaseDim.x/2,offsetY,streetWidth/2+mBaseDim.z/2);
    76.         CreateBuilding(tempPos);
    77.  
    78.         tempPos = new Vector3(streetLength-streetWidth/2-mBaseDim.x/2,offsetY,streetLength-streetWidth/2-mBaseDim.z/2);
    79.         CreateBuilding(tempPos);
    80.        
    81.         tempPos = new Vector3(streetWidth/2+mBaseDim.x/2,offsetY,streetLength-streetWidth/2-mBaseDim.z/2);
    82.         CreateBuilding(tempPos);
    83.        
    84.         //other building
    85.         for(int i = 1;i< Ninner-1;i++){
    86.            
    87.             float step = Random.Range(-stepInner/4,stepInner/4);
    88.            
    89.             CreateBuilding(new Vector3(streetWidth/2+mBaseDim.x/2,offsetY,streetWidth/2+mBaseDim.z/2 + i*stepInner + step));
    90.             CreateBuilding(new Vector3(streetWidth/2+mBaseDim.x/2 + i*stepInner + step,offsetY,streetWidth/2+mBaseDim.z/2));
    91.             CreateBuilding(new Vector3(streetWidth/2+mBaseDim.x/2 + i*stepInner + step,offsetY,streetLength-streetWidth/2-mBaseDim.z/2));
    92.             CreateBuilding(new Vector3(streetLength - streetWidth/2 - mBaseDim.x/2,offsetY,streetWidth/2+mBaseDim.z/2 + i*stepInner + step));
    93.            
    94.            
    95.         }
    96.        
    97.         //other building
    98.         for(int i = 1;i< Nouter;i++){
    99.            
    100.             float step = Random.Range(-stepOuter/4,stepOuter/4);
    101.            
    102.             CreateBuilding(new Vector3(-streetWidth/2-mBaseDim.x/2,offsetY,-streetWidth/2 - mBaseDim.z/2 + i*stepOuter + step));
    103.             CreateBuilding(new Vector3(streetLength + streetWidth/2 + mBaseDim.x/2,offsetY,-streetWidth/2 - mBaseDim.z/2 + i*stepOuter + step));           
    104.            
    105.             CreateBuilding(new Vector3(-streetWidth/2-mBaseDim.x/2 + i*stepOuter + step,offsetY,-streetWidth/2-mBaseDim.z/2));
    106.             CreateBuilding(new Vector3(-streetWidth/2-mBaseDim.x/2 + i*stepOuter + step,offsetY,streetLength+streetWidth/2+mBaseDim.z/2));
    107.            
    108.            
    109.  
    110.         }
    111.        
    112.     }
    113.  
    114.     void CreateBuilding(Vector3 position){
    115.        
    116.         float currHeight;
    117.        
    118.         Vector3 curPosition = position;
    119.  
    120.         ++numBuildings;
    121.  
    122.         Transform c_parent = null;
    123.         Transform b = null;
    124.         if (bases.Length > 0)
    125.         {
    126.             b = (Transform)Instantiate(bases[Random.Range(0, bases.Length)], curPosition, Quaternion.identity);
    127.             b.name = "Base" + numBuildings;
    128.             b.Rotate(0,angles[Random.Range(0, angles.Length)],0);
    129.            // b.parent = block;
    130.             c_parent = b;
    131.         }      
    132.        
    133.         if (floors.Length > 0)
    134.         {
    135.             int numFloors = Random.Range(1, maxFloors);
    136.  
    137.             for (int i = 0; i < numFloors; ++i)
    138.             {
    139.                 curPosition.y += 4;
    140.                 Transform f = (Transform)Instantiate(floors[Random.Range(0, floors.Length)], curPosition, Quaternion.identity);
    141.                 f.name = "Floor" + numBuildings + "_" + i;
    142.                 f.parent = c_parent;
    143.                 c_parent = f;
    144.                 f.Rotate(0,angles[Random.Range(0, angles.Length)],0);
    145.             }
    146.         }
    147.        
    148.         curPosition.y += 4;
    149.  
    150.         if (roofs.Length > 0)
    151.         {
    152.             Transform r = (Transform)Instantiate(roofs[Random.Range(0, roofs.Length)], curPosition, Quaternion.identity);
    153.             r.name = "Roof" + numBuildings;
    154.             r.parent = c_parent;
    155.             r.Rotate(0,angles[Random.Range(0, angles.Length)],0);
    156.         }      
    157.        
    158.         b.localScale = new Vector3(mScale,mScale,mScale);
    159.     }
    160.    
    161. }
    162.  
     
  29. MrSmive

    MrSmive

    Joined:
    Oct 12, 2010
    Posts:
    428
    you know my views on the save part Bren, but the custom/drawing a city part i personally think is less necessary but would make one tasty asset, that reminds me, got a few sketches to draw up, showing the use of nodes and such, had a few ideas floating around my noggin for that one. But i am going to be AWOL for a few days will get some stuff for you, to look over when i get back mate.
     
  30. MrSmive

    MrSmive

    Joined:
    Oct 12, 2010
    Posts:
    428
    oh baby that looks oh so much better man, shadows make a huge difference, will give this a try when i get back man.

    Btw for now, for this free one, do you want the same set up, same size building blocks with similar texture, or have you set a way to distinguish between building types, so as if the base was glass instead of the brick and door, a glass base would go above it and then a glass roof?

    Also as you got the fps in, ill make some with negative space, nothing complex, well actully come to think about it, if you no longer rotate the building blocks, and instead have 4 versions of each, i can put stairs in and windows, and you would in theory be able to enter every building and explore every floor, what do you think man?
     
  31. rockysam888

    rockysam888

    Joined:
    Jul 28, 2009
    Posts:
    650
  32. CraigSnedeker

    CraigSnedeker

    Joined:
    Jul 9, 2010
    Posts:
    30
    Looks awesome, good work!
     
  33. Bren

    Bren

    Joined:
    Aug 28, 2008
    Posts:
    191
    Hey MrSmive, sorry I didn't see this message sooner.

    Sure, that's no problem, I can't definitely support different building styles and make sure bases/floors/roofs don't get mixed up.

    I love that idea! I wouldn't need 4 different versions for the interiors to "line up". It would be very easy for me to build the whole building before giving it a random rotation, to keep bases/floors/roofs oriented correctly to each other.
     
  34. MrSmive

    MrSmive

    Joined:
    Oct 12, 2010
    Posts:
    428
    your right, but will probably need more than 6 parts to make it convincing, really surprised at how well 6 parts actually work when making a city, 12 or 24 should work much better lolz.

    Im in the latter stages of UVmaping 130 something tilable parts for my rpg pack, but once there done ill go to work on this one
     
  35. Bren

    Bren

    Joined:
    Aug 28, 2008
    Posts:
    191
    Sweet!
     
  36. thellama

    thellama

    Joined:
    Mar 25, 2010
    Posts:
    360
    This is really cool, with enough forum support and cooperation we'll have our own city-gen kit.
     
  37. Quietus2

    Quietus2

    Joined:
    Mar 28, 2008
    Posts:
    2,058
    Very nice.

    You should look at Blender's city generator for some inspiration to take this project to the next level. It does some really neat things.



    Instead of a pool of textured models, they procedurally generate textures. Sampling and coloring from a source texture such as above to construct their building textures on the fly. It's like a texture atlas on steroids.

    http://arnaud.ile.nc/sce/tutorial_textures.php



    Results are pretty impressive.
     
  38. Nikolay116

    Nikolay116

    Joined:
    Mar 21, 2010
    Posts:
    421
    not that impressive, ok for far render, but not for games. Better use existing assets
     
  39. Muzzn

    Muzzn

    Joined:
    Jan 23, 2011
    Posts:
    406
    How can I get those shadows? I don't have pro or anything.
    BTW, it's awesome!
     
  40. cemC

    cemC

    Joined:
    Dec 23, 2010
    Posts:
    214
    that looks impressive but every building put on one square (one grid). For example , i want to make a city randomly, and there is a main road or rail road. How can i build it? are there any suggestions or ideas of some modifications in scripts?
     
  41. krial

    krial

    Joined:
    Mar 21, 2011
    Posts:
    3
    This is awesome! Will be nice to have some decent looking generic environment to test with!
     
  42. Viet4Lyfe

    Viet4Lyfe

    Joined:
    Apr 1, 2011
    Posts:
    69
    whoaaaaaa this is absolutly amazing! Is it possible to have a whole wack of textures and have the program select a random one for each building?
     
  43. Vinicius-skt

    Vinicius-skt

    Joined:
    Nov 15, 2012
    Posts:
    1
    How to use the script?
     
  44. AHP1204

    AHP1204

    Joined:
    Jan 18, 2013
    Posts:
    2
    this is just what i need to make my slenderman game (takes place in a city). thanks :)
     
  45. TheRealTomS

    TheRealTomS

    Joined:
    Sep 20, 2013
    Posts:
    1
    Hey, how do you actually generate a random city?