Skip to content

Developer notes — kids.kapish.splines.walls

unity

Shape

A wall is a closed cross-section extruded along a spline, so the heavy lifting is kids.kapish.splines.meshes' StripMeshBuilder. This package is thin: parametric WallProfile presets + a component that computes the strip, sweeps it, and emits collision.

  • Profiles are StripProfile subclasses with Closed => true. Across (0→1) spans the wall thickness (the strip's Left↔Right, = StripSettings.Width); Up is metres. Solid = rectangle; Hedge chamfers the top; Fence adds a pointed cap. v1 presets are convex, so StripMeshBuilder's fan caps are valid.
  • Thickness is StripSettings.Width; conform rides the strip's ConformToTerrain, so the base follows the ground. Height is constant (v1) — on the profile.
  • Collision is separate. Per-section BoxColliders walk the strip centre at ColliderSegmentLength, each sized thickness × ColliderHeight × segment, oriented along the segment, riding from the strip surface up. Deliberately ignores footing/top shaping — it only has to stop you walking through. (Convex-mesh colliders could replace these later for odd profiles.)
  • Non-destructive: additive baked mesh assets + GameObjects under Generated Wall; no terrain mutation, so walls don't take part in the flatten/drop bake — they just Rebuild() (they're IBakeable).

Known gaps (v1)

  • Joins — wall↔wall and hedge↔wall meeting aren't reconciled (no shared-end cap suppression / mitre yet). Mirror the path junction work when needed.
  • WindingStripMeshBuilder aligns winding to a computed outward normal, but if a profile reads inside-out, FlipFaces is the escape hatch.
  • Smoothing — flat per-face normals; hedges/rounded copings will want smooth normals later.
  • Height — constant; per-knot / curve-driven height is a later option.

File Structure

Runtime/
├── WallProfile.cs       # WallProfile + Solid/Hedge/Fence presets
├── WallMeshStrip.cs     # component: sweep + box colliders (IBakeable)
└── Carrot.Splines.Walls.asmdef
Editor/
├── WallMeshStripEditor.cs
└── Carrot.Splines.Walls.Editor.asmdef

Usage Guide

Build a wall

  1. Add a SplineContainer and draw the wall line.
  2. Add a WallMeshStrip (Add Component → Carrot/Splines/Wall Mesh Strip).
  3. Pick a Profile (Solid / Hedge / Fence) and set its Height.
  4. Set Strip Settings → Width to the wall thickness, and turn on ConformToTerrain so the base hugs the ground.
  5. Assign a Material and hit Rebuild.
csharp
using Carrot.Splines;        // StripSettings
using Carrot.Splines.Walls;
using UnityEngine;

var wall = gameObject.AddComponent<WallMeshStrip>();
wall.StripSettings.Width = 0.5f;            // thickness
wall.StripSettings.ConformToTerrain = true; // base follows the ground
wall.Profile = new HedgeProfile { Height = 1.6f, TopChamfer = 0.3f };
wall.Material = hedgeMaterial;
wall.Rebuild();

Notes

  • Collision is on by default — simple box colliders per ColliderSegmentLength metres, independent of the visual mesh. Turn off GenerateColliders if you don't need it.
  • Inside-out? Toggle Flip Faces and rebuild.
  • Profiles are swappable presets; a fence is a thin wall with a pointed cap, a hedge is a chamfered-top wall. Width (thickness) lives in Strip Settings, height on the profile.
  • Joins between walls (and a hedge coming off a wall) aren't reconciled yet — for now keep meeting walls as separate strips; mitred joins are coming.

Carrot