"Runtime world-building helpers"
- Hand-placing every prop in the scene editor doesn't scale; you want C# to build the world at boot.
- Build-validity checks via physics traces are flaky (water, felled trees, overlapping footprints).
- Decals sink into the ground; wires don't stretch between points.
A small set of spawn helpers + a data obstacle list is enough for most stylized games. Physics queries are the wrong tool for "can I place here?" when you already know every footprint you spawned.
Helpers worth having
FlatBox — models/dev/box.vmdl is a 50u cube. Scale with:
go.WorldScale = size / 50f;
renderer.MaterialOverride = terrainOrWaterMat;Remember: flat ground decals (water/roads) — top surface must sit above the ground plane top.
Prop — catalog model + bounds-sized static BoxCollider + register a placement obstacle.
Deco — renderer only (flowers, clutter) — no collider, no footprint.
Wire — thin box stretched between two points:
var delta = b - a;
go.WorldPosition = (a + b) * 0.5f;
go.WorldRotation = Rotation.LookAt(delta.Normal);
go.WorldScale = new Vector3(thickness, thickness, delta.Length / 50f); // if using the 50u box(needs verification) on exact scale axes for your box orientation — measure one wire visually.
Placement as plain data
record struct Obstacle(GameObject Go, Vector3 Pos, float Radius, bool IsWater);
// removable by GameObject when a tree is felled
// water flag lets creek-only buildables opt out of "blocked by water"Prefer this over scene traces for build-validity. Forbid placement inside the player's footprint too (see kinematic-movement-startedsolid).
Boot order
Managers → world builder → state. Mark runtime-placed structures for save/load with a small component (BuildId) and respawn through the same factory (saveload-without-drift).
Author builder math in meters; convert once with * 39.37f (sbox-units-are-inches).
Helpers encode the engine quirks (dev box size, collider policy, facing) in one place. Obstacle records are authoritative for footprints you created — no trace miss, no trigger asymmetry — and can carry semantic flags physics shapes don't have.