Walkthroughs
Step-by-step recipes for the most common jobs. Each one takes about ten minutes. The Quick Start comes first: it makes your first piece.
1. Building in your own first-person game #
You have a level and a player that walks around. You want the player to build with your pieces.
- Make your pieces. For each model: kit window > Make Buildable > drop it in > check the preset > Create Piece. Make one foundation, one wall and one floor to start.
- A catalog. In your data folder: Create > All In One Runtime Building Kit > Piece Catalog, and drag your pieces into it. The catalog is the list of pieces this world allows; saves and multiplayer name pieces through it.
- The world. In your scene: GameObject > Create Empty, name it "Build World", Add Component > All In One Runtime Building Kit > Build World, and drag your catalog into Catalog.
- The Builder. On your player: Add Component > All In One Runtime Building Kit > Builder. Set Aim Origin to your camera and drag your pieces into Hotbar. (The preview materials are filled in for you when left empty.)
-
Input. With no code: add Sample Input Source and Sample Build Input (in
Samples/Scripts) to your player. They use the Input System when it's active and the old Input Manager otherwise: number keys, left click, R, X, G, U, Z, Y. Or call the Builder from your own input code:if (Input.GetKeyDown(KeyCode.Alpha1)) builder.SelectSlot(0); if (Input.GetKeyDown(KeyCode.R)) builder.Rotate(1); if (Input.GetMouseButtonDown(0)) builder.Confirm(); if (Input.GetMouseButtonDown(1)) builder.Cancel(); -
Press Play. Aim at the ground: the foundation preview follows your aim, green where it fits, red with a reason where it doesn't. Place a foundation, then a wall on its edge.
- Costs (optional). Create > All In One Runtime Building Kit > Resource Type for each resource (Wood, Stone). On the Build World: Add Component > Simple Resource Inventory, add starting amounts, and drag it into the Build World's Resource Provider. Give each Piece Definition a Cost. Your own inventory can take over later (see Extending).
- Saving (optional). From your save menu:
world.Save("slot1")andworld.Load("slot1").
Check the Base Building sample: it is exactly this, with a HUD.
2. Furniture in a room #
Your rooms are level geometry (or built pieces); players decorate them.
- Make Buildable each piece of furniture. The kit suggests the preset from the shape:
- Furniture for tables, chairs, beds, plants: they stand on floors and on top of tables and shelves.
- Wall Mounted for pictures, wall lamps and shelves: they go flat against walls.
- For a ceiling lamp, choose Furniture, then in the Piece Definition set Goes On to Ceiling.
- Keep Needs Support on (the default) so nothing hangs off the edge of a table: the reason says "Hangs over the edge of Table_01".
- Add the pieces to the Builder's Hotbar (or a second Builder for an "interior mode").
- Press Play: books go on the table, pictures on the walls; T turns a placed piece where it stands, G moves it.
The Furniture and Interior sample shows all of these.
3. A top-down or strategy camera #
The Builder doesn't care where the camera is; it needs a ray.
- On the Builder, turn Update Automatically off.
- Set Reach From to the character, so reach is measured from the character rather than from a camera far above. (Left empty, it is measured from the camera; set Max Distance to 0 on a piece to turn the check off.)
- Each frame, aim from the mouse pointer:
Ray ray = camera.ScreenPointToRay(Input.mousePosition); builder.Refresh(ray); if (Input.GetMouseButtonDown(0)) builder.Confirm(ray);
The Top Down sample does this, with both input systems.
4. Building together (multiplayer) #
With Netcode for GameObjects 2.x installed:
- On the Build World: add Network Object and Netcode Build Authority.
- Put your player prefab (with its Builder) in the Network Manager's Player Prefab, and enable the Builder only for the owner.
- Host and join. The host checks every request with the same rules and costs, and everyone sees the same world.
The whole story, including permissions and late joiners, is in Multiplayer; the Multiplayer sample is ready to play.
5. Wall decorations, free turning and looks #
- On a Piece Definition (a shelf, a lamp, a sign), set Goes On to Floor and tick Wall in Also Goes On: it now stands on floors and tables and hangs on walls. For a picture, keep Goes On on Wall; Turns On Walls lets players spin it to portrait.
- Decor that should look placed by hand: Own Rotation Step with 0 (turns freely), Random Turn 20 to 45, and Allow Tilt for things that lean (books).
- Looks: add a few colours (Tint) or materials. Players pick one with
NextVariantand repaint later with the Paint tool. - Limits: Max Per Player 2 on a bed, or a Category Limit on the Build World.
6. Rows, areas and blueprints #
- Tick Allow Rows on walls and fences, Allow Areas on foundations and floors (the presets do).
- Give the player a key that sets
builder.Shape(Single, Line, Area): on press callBeginShape(), on releaseConfirm(). The sample input does exactly this. - Blueprints: a key for
SetTool(BuilderTool.Copy), then Confirm on a building copies it and starts stamping. Ship ready-made ones as Blueprint assets and callStartStamp(asset.Blueprint).
7. Areas and your own rules #
For an area, no code: add a Build Zone (box or sphere) set to Forbid ("Keep the spawn clear") or Only Allow (a plot). See Gameplay.
For anything else ("not underwater", "only on your own land", "not at night"), add an IPlacementRule to the
Build World's validator. The player sees your reason in the preview, and a multiplayer host checks it too. A complete
example is in Extending.