Other Structures

👍

Reminder - Keep Daily Backups

When working on a strategy game with a kit as big as the Complete Kit - always keep a working daily backup! Save yourself the trouble of rolling-back changes and losing work.

Can I really build any sort of structures?

All of the above types of structures in the City Building Kit documentation pages are actually controlled by a single multi-functional StructureCreator. It builds anything, different prefabs and SO (ScriptableObject) descriptors; this includes array-builds, for walls and fences, instant builds (without construction sequence) and whatever you can dream up for your game

1348

What is the best way to create the "base buildings" for a new player?

For instance, if I want to create a Toolhouse the first time a player starts the game, what is the best way? This is a feature in the GameManager for loading called LoadFirstTown - so you can automate the initial map loaded for new players.

Save a map file to your server, for example the following 00InitMap.txt file shown below. Put this map file on the server with the other maps. The initial town load is automated, at least till the player saves locally; or comment the line in SaveLoadWWW.cs start function (if local save), and load the initial town each time you run the game in editor. Also, you can create and save a different local map, then set it as the initial town. All players will load this initial town.

###StartofFile###
###PosStruct###
Building,Summon,88,3,0,0
Building,Forge,89,3,-384,271.5
Building,Generator,90,3,0,543
###GridStruct###
###Construction###
###Removables###
TreeC,0,0,2,2
TreeB,1,0,2,6
ClamB,2,0,3,3
ClamC,3,0,3,10
ClamB,4,0,4,21
TreeA,5,0,4,29
ClamB,6,0,5,14
TreeB,7,0,5,33
ClamB,8,0,8,8
TreeA,9,0,8,16
TreeD,10,0,8,20
TreeB,11,0,8,32
TreeC,12,0,9,2
ClamA,13,0,9,31
ClamC,14,0,10,8
ClamA,15,0,10,11
ClamC,16,0,10,15
ClamA,17,0,10,32
TreeD,18,0,11,12
TreeD,19,0,11,21
TreeD,20,0,11,31
ClamA,21,0,12,19
ClamA,22,0,13,4
TreeD,23,0,13,12
TreeA,24,0,13,22
TreeC,25,0,13,30
ClamB,26,0,13,31
TreeA,30,0,16,27
ClamA,31,0,16,29
TreeB,32,0,17,11
TreeA,33,0,17,22
ClamA,34,0,17,23
TreeB,35,0,17,26
TreeD,37,0,18,27
ClamA,38,0,19,16
ClamA,39,0,19,25
ClamC,40,0,20,28
TreeA,41,0,21,2
TreeB,42,0,21,7
TreeD,43,0,21,9
TreeC,44,0,21,23
TreeA,45,0,21,26
ClamA,46,0,21,31
ClamB,47,0,22,15
TreeA,48,0,22,16
TreeD,49,0,22,18
ClamB,50,0,22,21
TreeC,51,0,22,31
ClamB,52,0,23,3
ClamB,53,0,23,11
TreeA,54,0,23,19
TreeC,55,0,24,8
TreeD,56,0,24,11
TreeD,57,0,24,30
TreeD,58,0,25,13
TreeB,59,0,25,18
TreeD,60,0,25,33
ClamC,61,0,26,14
ClamC,62,0,26,19
ClamB,63,0,26,27
TreeD,64,0,26,29
TreeC,65,0,27,2
ClamB,66,0,27,7
TreeB,67,0,27,10
TreeA,68,0,27,11
TreeA,69,0,27,15
ClamC,70,0,27,17
ClamB,71,0,27,25
TreeB,72,0,28,18
TreeC,73,0,29,5
TreeB,74,0,29,33
TreeD,75,0,30,2
ClamC,76,0,30,13
TreeC,77,0,30,20
TreeB,78,0,30,23
TreeA,79,0,30,24
TreeC,80,0,31,16
ClamC,81,0,31,26
TreeC,82,0,32,2
ClamC,83,0,32,9
TreeC,84,0,32,11
TreeA,85,0,32,20
ClamA,86,0,32,24
TreeB,87,0,33,8
###RemovableTimers###
###Numerics###
90,-1,-1
0.00,0
1,1,1,1,1,1,1,1,1,1
1,1,2,2,3,3,4,4,5,5
0,0,0,0,0,0,0,0,0,0
###Stats###
90,108,1,0,0,100,99500,98900,3,500000,500000,5,True,True,True,True,True,True
2/16/2017 7:35:35 PM
###EndofFile###

What about normal structures?

Normal structures are just like any other structure we've discussed before - just without any special qualities in the SO, and no special changes to the code. Look at the classroom example for details.

435

Classroom structure

Where are the prefabs?

All of the game object prefabs are set in the ScriptableObjects at the path Assets/CityBuildingKit/Resources/Assets/
For example take a look at the WallsCategory.asset file below :

625

Game scene Game Manager > SaveLoadMap

In addition, you will want to look at GameManager > Creators > BuildingCreator (prefabs are also there) This is discussed in the Buildings > Part 2: Customize Menus section of the documentation. Prefabs are used by the creator for construction and by SaveLoadBattle for loading during battle.

GameManager > Creators > BuildingCreator

In the GameManager > Creators > BuildingCreator we have the list of game object prefabs used by the creator in addition to certain build settings used by the Scripts/Creators/BaseCreator.cs script. Let's describe these below. But first, here's how to open the BuildingCreator Inspector.

273

Game scene Game Manager

365

Normal structure prefabs in the BuildingCreator

In the Inspector you'll notice a few arrays, here's a description of each one. It's the same for every type of game object you can build in the game except for the RemovableCreator (removables are not for players to construct but rather remove -- see Player Removable Objects doc for details)

Array TitleDescription
Structure PfThe structure prefab.
Grass Pf1x1 to 5x5 dark green grass collider grid prefabs list. These you don't have to edit, they are shared by all structures in the game based on their grid size.
Construction PfUnder construction prefab list. There's 3 different sizes of this for 1x1 to 3x3 grid size construction projects.
Grass TypesSize of this array matches the the Structure Pf array size. We tell which Grass Pf element to use with each structure. Depends on structure size whether they take 1x1 (Grass Pf element 0) like a wall segment or 3x3 (Grass Pf element 2) like the large gold vault. Tatami is the only object that takes grass collider 5x5 ( Grass Pf Element 4).
Construction TypesArray size matches Structure Pf. Like grass types, we match the construction prefab grid size too. Since there's 3 different sizes of construction prefabs, this ranges from values 0 to 2. By default, we set most structures to use the 3x size.
Pivot CorrectionsArray size matches Structure Pf. Odd size grid structures (1x1 and 3x3) need a pivot correction so they don't appear accidentally off-center, taking more grid space than necessary. Pivot Correction does this.
Is ArrayArray size matches Structure Pf. If set to 1, uses the row making field builder for construction instead of the usual construction. The only objects that use this are the wall segments that let you pick a start and end point and automatically constructs a repeating row of the structure between the points.
Is InstantArray size matches Structure Pf. For items you set TimeToBuild to 0 (instant build) in the SO, you also want to set the elements Is Instant boolean to 1 in this array. The only objects that use this in the demo are the wall segments.

SO Example of a Normal Structure (Classroom)

If you're just building a normal city-building game and don't need to generate resources, store resources, or units in your building - you can look at the Classroom building example included in the City Building Kit which doesn't have any special qualities.

516

What about animated structures?

For an animated normal building example, look at the Wizard Academy building. the SO is the exact same, although the prefab follows the Buildings > About Animated Prefabs section of the documentation on the left category list.