Appearance
kids.kapish.splines
unity
Headless spline-path core built on Unity Splines: sample spline containers into terrain-conformable path-strip ribbons.
Installation
Add to your Unity project's package manifest:
json
{
"kids.kapish.splines": "file:../../src/unity/kids.kapish.splines"
}Requires Unity 6000.0+, kids.kapish.terrains, and com.unity.splines.
Architecture
Scope
This is the headless core of the path system — data structures and the spline→strip calculation, with no MonoBehaviours and no mesh generation. The authoring components, Scene-view preview, and mesh baking live in kids.kapish.splines.paths, which depends on this. The split lets you sample splines into strip geometry for gameplay (object placement, AI navigation, distance queries) without dragging in the rendering layer.
kids.kapish.splines spline → Strip (this package)
▲
kids.kapish.splines.paths Strip → Mesh + componentsStripCalculator
Walks each spline at SampleSpacing, builds a centre line, widens it to Width with mitre handling (MiterLimit), optionally conforms each sample to the terrain via an ITerrainSampler, and applies end-falloff so paths sink into the ground at their ends. Conforming is delegated entirely to kids.kapish.terrains: pass an ITerrainSampler, or let it construct a RaycastTerrainSampler from the settings. There is no dependency on any terrain tool — point it at a raycast, heightmap, or tool-specific sampler interchangeably.
File Structure
Runtime/
├── Strip.cs # Ribbon data
├── StripSample.cs # Per-sample struct + flags
├── StripSettings.cs # Strip shape config
├── StripCalculator.cs # Spline → strip
└── Carrot.Splines.asmdefDependencies
| Dependency | Kind |
|---|---|
kids.kapish.terrains | runtime — terrain conforming via ITerrainSampler |
com.unity.splines | runtime — SplineContainer sampling |
Build
Import via Unity Package Manager. Requires Unity 6000.0+.
Usage Guide
Headless spline-path core: sample spline containers into terrain-conformable path-strip ribbons.
Generating a strip
csharp
using Carrot.Splines;
using Carrot.Terrains;
using UnityEngine;
using UnityEngine.Splines;
SplineContainer container = GetComponent<SplineContainer>();
var settings = new StripSettings
{
Width = 4f,
SampleSpacing = 1f,
ConformToTerrain = true,
SurfaceOffset = 0.05f,
RaycastDistance = 500f,
};
// Default raycast sampler is created automatically when none is passed.
Strip[] strips = StripCalculator.ComputeAll(container, settings);
// ...or supply your own sampler (e.g. a heightmap-backed one):
ITerrainSampler sampler = new RaycastTerrainSampler(LayerMask.GetMask("Terrain"), 500f);
Strip[] conformed = StripCalculator.ComputeAll(container, settings, sampler);Reading the samples
csharp
using Carrot.Splines;
Strip strip = StripCalculator.Compute(container, 0, settings);
foreach (StripSample s in strip.Samples)
{
// s.ArcLength, s.HalfWidth, s.Slope, s.Camber, position/tangent ...
// e.g. place objects along the path, drive AI, query distance.
}Tips
- No rendering here — this package produces strip data. For meshes, gizmos, and components add
kids.kapish.splines.paths. - Terrain conforming cost — conforming raycasts once per sample; widen
SampleSpacingon long paths that don't need fine surface tracking. - Swap the sampler — pass any
ITerrainSamplerto conform against something other than physics colliders (seekids.kapish.terrains).