ModularConstruction

Author: Divinux

Description
This is a really basic version of a modular building system. Rust and Unturned use this kind of thing for houses and such, but it can also be used for weapons, corridors, spaceships, vehicles, anything that you can provide "building blocks" for.



Usage
Set up the manager object
 * Create an empty GameObject and call it BuildingManager or similar. Attach this script to it.
 * Set the size of the Prefabslist to however many modules you have.

Set up a module
 * Create an empty GameObject. Give it a descriptive tag like "wall". Also name it "WallModule" or similar.
 * Add a model as a child to it.
 * Add a collider as a child as well.
 * Add a new sphere as a child. Tag it "handle". You can set this tag in the inspector of this script.
 * Make sure the sphere you just created has a collider, then tick the "Is Trigger" box.
 * Disable the sphere's mesh renderer.
 * Position this sphere where you want objects to connect. Your prefab may have multiple connections.
 * Make a prefab for this module.

Set up a preview
 * Just keep using the object you just created and make the following changes:
 * Add a transparent material to the mesh, to make it look like a ghost preview.
 * Disable the collider.
 * On all your handle children, disable the collider and enable the mesh renderer.
 * Name the object "WallPreview" or similar and make a prefab for it.

Add references to the manager
 * Now go back to the inspector of your BuildingManager and just drag your prefabs into the list "Prefabs".

You're done!

History

 * 12 March 2016 - Release