Single Player Example Scene Run Down

Hi, i am the creator of Modular Building System, before i created this tool for Unity3D i was and still am working on my own game. That's why i created this building system in the first place. After posting up some progress reports of the system to my youtube channel Medieval Survival Game i had a few people asking me for the building system scripts which is fine but it's not as simple as it sounds. My game already has an **Item System**, **Inventory System** and an **Action Bar,** yours may also have it's own system which is similar or vastly different so this example scene doesn't use any **UI**, it merely serves to show how the building system works. I will add some UI example scenes along with tutorials on integrating the building system into game projects asap.

## Scene Rundown

Once the scene has loaded press play and have a play with the system first to see how it functions.

You can move with **W**, **A**, **S**, **D** and equip building modules with the keys 1-8.

1. **Foundation** - This is the first module placed.
2. **Pillar** - Placed on foundations, ceilings and stacked on top of each other.
3. **Wall**- Placed on foundations, ceilings and stacked on top of each other. Must have 1 pillar at both sides.
4. **Window**- Placed on foundations, ceilings and stacked on top of each other. Must have 1 pillar at both sides.
5. **Doorway** - Placed on foundations, ceilings and stacked on top of each other. Must have 1 pillar at both sides.
6. **Ceiling** - Attached to Walls/Windows/Doorways and can be snapped to other Ceiling Modules. Must have 1 pillar at each corner.
7. **Stairs** - Placed on foundations, ceilings and stacked on top of each other. Must have 1 pillar at each corner.
8. **Remover** - Remove building modules.

Do some building and see how the system works etc...

Once you've had enough of playing around ;), have a look at the Hierarchy tab you will find some objects.

**Cross Hair** - This is used to display a dot at the center of the screen, it can pretty much be ignored for the purposes of this rundown.

**World** - This has the terrain, water, trees and a previously made building, this can also be ignored for now.

**FPSController** - This is one of the standard fps controller prefabs that comes with unity, it is essentially the "Player" object and is controlled with **W**, **A**, **S**, **D**, **SPACE** etc... This is the main area of interest for understanding how the equipping of items works.

## FPSController

   The FPSController has several components attached to it.

For the purposes of this example we only need to worry about the EquipBuildingItems Script. As you can see in the image on the left, there is a public array called Building Items, this array stores the Building Item Prefabs which can be dragged into the inspector.

The Update function listens for the keys 1-8 to be pressed, upon being pressed one of the modules will be equipped.

## Items

Items are simply prefabs that get instantiated at run time. They consist of several prefabs, scripts and meshes.

    Let's look at the foundation item. The main prefab ItemFoundation.prefab is the prefab that gets instantiated when we equip the foundation building module. The prefab has the script ItemFoundation attached to it, this script has a reference to the Building Prefab, The Foundation Prefab and the Foundation Placement Prefab.

1. Item Prefab - (ItemFoundation) This is the prefab that gets instantiated, it has a script componant attached to it.
2. Item Prefab Script - This is the script attached to the Item Prefab
3. Item World Prefab - This is the Prefab that gets spawned into the world once a user/player places a building module.
4. Item Placement Prefab - This is used as an indicator acting as preview when players are building. It lets the user know if he/she can place the current module at the current position.

This is the basic structure that most items use, normally only the foundation has a Building Prefab field since the only time new buildings get spawned is when foundations are being placed on the terrain.

## In The Next Example Scene

In the next example scene i will focus on using the system with an ItemDatabase System + Inventory + Action Bar showing how to integrate the building system into your own games item system, allowing you to hold building modules in an inventory and using the action bar to equip them.