# Splinecraft Roads, pipes and cables from splines, for Unreal Engine 5.6, 5.7 and 5.8. Everything works the same placed in the editor or spawned while the game runs, and replicates to every client. - **Roads** meet at junctions by themselves, cut and fill the landscape, turn into bridges and tunnels where the terrain asks for it, paint their lines, and come with lanes any traffic AI can read: crossings, T junctions, corners, roundabouts with one to three lanes, highway ramps, crosswalks and traffic signals. - **Pipes** bend at every spline point, change size, branch into tees and crosses, and hold on to the nearest wall, floor or ceiling with supports. Built as a mesh, or from your own kit of static meshes. - **Cables** hang as real cables do, between poles a road strings by itself or between any two actors, and sway in the wind in the material. Switch on physics and a cable becomes a rope: it falls, swings, rests on what it touches, can be cut and reeled, holds and lifts what hangs from it, tows, and costs nothing once it sleeps. On top: a draw mode to lay roads, pipes and cables with the mouse, OpenStreetMap import, PCG nodes, export of the lanes to ZoneGraph, a setup check, and baking to Nanite static meshes. Windows and Linux (Linux builds; it has been run on Windows). Measured on the development PC, UE 5.8, in the editor: | | Time | |---|---| | Rebuild of 24 streets and 144 junctions, from nothing | 0.9 s | | The same with one street moved (only it and the 3 streets it crosses are built again) | 0.2 s | | A road spawned in the game, landscape cut included | 18 ms | | One simulated 20 m rope, awake | 0.13 ms per frame | | One simulated 20 m chain, awake | 0.18 ms per frame | | A rope asleep | nothing | ## Quick start: a small town in 15 minutes 1. Enable **Splinecraft** and restart the editor. PCG and ZoneGraph come on with it. 2. Open a level with a landscape. In 5.6, the landscape needs **Enable Edit Layers** on; from 5.7 every landscape has them. 3. Pick the **Splinecraft** mode in the modes menu (next to Landscape and Foliage). In its panel choose **Road** and leave the profile empty for a two lane street. 4. Click on the landscape to place points: the second click makes the road, each click after it adds a point. **Backspace** takes the last point away, **Enter** or **Esc** finishes, **Ctrl+Z** undoes point by point. The terrain under it is cut and filled as you go. 5. Draw a second street across the first: a crossing appears. End a third one on the side of another: a T. End two streets at the same spot: a corner. A click within 3 m of a road's end or middle snaps to it. 6. Drop a **Splinecraft Roundabout** where four streets should meet and draw the streets into its center: they stop at the ring and give way to it. 7. Make a profile (**Content Browser > Miscellaneous > Data Asset**, class **SPCRoadProfile**), give it two lanes each way and sidewalks, tick **Crosswalks** and **Traffic Signals**, and set it on the main street. Its junctions get zebra crossings, stop lines and signal heads that cycle by themselves. 8. Or skip the drawing: export an area from openstreetmap.org and click **Import Open Street Map File** in the mode's panel. 9. Click **Check Setup** in the panel and fix what the Message Log lists. 10. Press Play. The roads are there, the lanes are in `Get Road Network > Get Lanes`, and the signals turn green and red the same way on every client. ## Roads A **Splinecraft Road** is a spline and a **profile**. Points can be moved, added and given any height; the road stays level across (it never twists) and narrows on the inside of curves tighter than half its width, so it never folds over itself. ### Profiles `SPCRoadProfile` is a Data Asset with the lanes from left to right. Each lane has a type (driving, shoulder, sidewalk, bike, parking), a direction (forward along the spline, backward, or none), a width, a speed, a height over the road and a material. A lane higher than the one next to it gets a curb between them: that is a sidewalk. Ready profiles to start from are in `/Splinecraft/Profiles`: `DA_SPC_Street`, `DA_SPC_ParkingStreet`, `DA_SPC_OneWayStreet`, `DA_SPC_Avenue` (crosswalks and signals on), `DA_SPC_Highway`, `DA_SPC_CountryRoad` and `DA_SPC_DirtTrack`, plus `DA_SPC_WaterPipe` and `DA_SPC_Duct` for pipes. Their surfaces (`M_SPC_Asphalt`, `M_SPC_Sidewalk`, `M_SPC_Shoulder`, `M_SPC_Dirt`) are laid over the world's X and Y, so roads and junctions share one continuous surface; **TileMeters** sets how much ground one texture covers. Copy a profile to change it. The profile also sets the road's thickness, how the terrain meets it (side slope, reach, how far below the surface it is cut), its bridges and tunnels, its markings, its props and its wires. One profile can serve any number of roads; a road without one uses the default two lane street. ### Junctions The road network (a world subsystem) looks at every road whenever one changes, a moment later, and makes: - **Crossings** where two roads run over each other at about the same height (2 m by default) and both go on past it. - **T junctions** where a road ends within 4 m of another's side. - **Corners** where road ends meet, none of the roads going on past them: two at an angle, or three and more together. Two ends that go straight on into each other are left as one road after the other. - **Roundabouts**: a road running into a **Splinecraft Roundabout** meets the ring where it goes in and where it comes out, and its piece inside the ring is left out. The roundabout has a radius, one to three lanes going round with a dashed line between them, a raised island with an apron long trucks can ride over, and a raised splitter island on every two-way road meeting it (120 cm wide at the ring, narrowing to a point 12 m out). With no profile set, **Ring Material** and **Shoulder Material** paint the lanes going round and the shoulder outside them. - **Ramps**: an end meeting another road's side at less than 25 degrees runs into it, or out of it. There is no junction: the ramp stops where its edge reaches the other road, a gore fills the wedge between the two with the ramp's edge line along it, and its lanes join the nearest lane going their way. Off with **Merge At Shallow Ends**. Junction corners are rounded curves between the roads' edges. Sidewalks go round the corners at their height, with the curb facing the junction. Roads more than 2 m apart in height where they cross do not meet: the higher one becomes a bridge over the other, with 3 m to spare on each side. ### Lanes that start or end partway **Lane Ranges** on a road make a lane of its profile start or end partway along it, growing from nothing or narrowing to nothing over a taper (60 m by default): a lane drop, an added lane, or an auxiliary lane between two ramps. The road keeps its width; the lane outside it (a shoulder, usually) takes the room. The edge line slides in with it, the dashed line ends where the lane has gone, and its traffic merges into the next lane in. ### Banked curves and parallel roads Set **Max Bank Degrees** on a profile and its roads tilt into their curves: 6 for a highway, 10 for a race track, 0 (the default) keeps them level. The tilt on each curve is what the profile's fastest lane asks for at that radius, up to the most you set, so a wide curve tilts a little and a tight one all the way. It comes in and goes out over **Bank Transition Meters**, and the road is level at its ends, at its junctions and where a ramp meets it. The mesh, the lanes handed to traffic and the terrain under the road all follow the tilt. **Get Bank Degrees** reads it at any distance. A roundabout's ring never banks. **Make Parallel Road** lays a second road beside the selected one, its center the distance you give to the right (negative to the left), the same profile and settings, running the other way when **Reversed**. With a one way profile the two make a divided road with a median. In the Details panel the button of the same name uses **Parallel Gap Meters**, **Parallel On Left** and **Parallel Reversed**. The new road is made once and is yours to edit; it doesn't follow the first when you change it. ### Markings, crosswalks and traffic signals With **Paint Lines** on (the default), a road paints its edge lines inside the outer lanes, a dashed line between lanes going the same way, and a center line between the two directions (dashed, solid or double, per profile or per lane). A road ending at a junction gets a stop line; one running into a roundabout, a give way line. Paint is a separate mesh without collision, 1 cm over the road, in the plugin's white and yellow paint or your materials. **Crosswalks** put a zebra crossing across every arm of the junctions the road meets, 1 m out of the junction, with the stop line moved back behind it. `Get Crosswalks` on the network gives where each one is, for pedestrians. **Traffic Signals** give the junctions the road meets one phase per road (both arms of a road go together), and every arm stops. Each phase is green, yellow, then all red for as long as that road's profile says (20, 3 and 2 s by default). The state comes from the server's clock, so every machine shows the same without sending anything. The junction builds a pole on the curb at each stop line, with an arm over the lanes and a head of three lamps facing the traffic; the lamps light in the plugin's signal material. Roundabouts never get signals. ### Terrain, bridges and tunnels In the editor the roads shape the landscape through an edit layer, **Splinecraft Roads**: under the road the terrain goes to its height less 5 cm, and beside it the terrain lies between two 35 degree slopes from its edges, cutting hills and filling valleys. Deleting the road gives the terrain back. Bridges and tunnels come from the terrain as it was before the roads. A road 6 m or more over the ground becomes a bridge (deck, parapets, piers every 30 m at most, never on a road below); 8 m or more under it, a tunnel (tube, portals, wing walls, terrain kept over the ceiling). The limits are in the profile. For the landscape to open at a tunnel's portal, its material needs a **Landscape Visibility Mask** node and Blend Mode Masked. In the game, a road spawned or moved edits the landscape's collision and its height texture on the GPU, and gives them back when it goes. For that the landscape needs Nanite off and Collision Mip Level 0; for tunnels spawned in the game, **Use Dynamic Material Instance** on and the plugin's `MF_SPC_RuntimeHoles` multiplied into its Opacity Mask. A landscape that streams back in is shaped again. With World Partition the roads are always loaded, since the network needs all of them. ### Props and wires **Props** in the profile place meshes along the edges: **Spaced** puts one every so many meters (posts, lamps, signs), **Continuous** lays bent meshes end to end (guard rails, fences). Side, distance from the edge, height, turn, scale and which ground they go on (plain road, bridge, tunnel) are per rule, and they stay 3 m clear of junctions. `Get Prop Transforms` tells where each one stands. The plugin comes with a small kit in `/Splinecraft/Props`, already on the ready profiles, to use as it is or to copy the rules from: - `SM_SPC_GuardRail`: 4 m of W beam on two posts, laid Continuous along both edges of `DA_SPC_Highway`. - `SM_SPC_Barrier`: a concrete barrier, laid Continuous down the highway's median. - `SM_SPC_StreetLamp`: a 3.9 m lamp post on both sidewalks of the streets and the avenue. The lantern glows, but it is a mesh, not a light: add your own lights where the game needs them. - `SM_SPC_Manhole`: a manhole cover in the right lane of `DA_SPC_Street`, `DA_SPC_OldStreet` and `DA_SPC_Avenue`, with no collision. - `SM_SPC_Sign`: a pole and a blank yellow warning plate on `DA_SPC_OldStreet` and `DA_SPC_CountryRoad`. Put your own symbol on the plate's material (slot 1). `DA_SPC_OldStreet` is the street with worn asphalt (`M_SPC_WornAsphalt`). The lamp, the barrier, the manhole cover and every texture are CC0, from Poly Haven. **Wires** string cables between the poles of a spaced prop rule, on both sides, one per socket of the pole's mesh or per attach point you give. Poles farther apart than **Max Span** (60 m) get none. ### Baking **Bake Meshes** on a road makes a Nanite static mesh of it, its paint, wires and the junctions it meets first, with complex collision, in `/Game/Splinecraft/Baked`. The bake is used while the road would build the same; change it and the built mesh comes back until you bake again, into the same asset. **Clear Bake** goes back. Save the level before baking: the asset is named after it. ### Roads at runtime and in multiplayer `Spawn Actor` a Splinecraft Road, set its spline points and call **Rebuild Network**, or just let the network rebuild on the next frame. On a server, roads, pipes, cables and roundabouts send their spline and settings to the clients, who build the same; a client joining late gets everything as it is. Profiles must be assets to reach the clients. Editing is incremental: the network finds the junctions again (a few milliseconds even for a town), but a road is built again only when something it is built from changed, and a junction surface only when its shape did. ## Railway tracks and switches A road whose profile has a lane of type **Rail** is a track: rails and sleepers are built along that lane, over the terrain, the bridges and the tunnels like any road. **DA_SPC_Railway** is a single track on ballast to start from. **Rail Gauge Cm**, **Sleeper Spacing Cm** and the two materials are on the profile. - **A switch** is a track ending on another track's side at a shallow angle, 10 degrees or so and under 25: draw the branch starting or ending beside the main track. The branch is cut at the main track's edge, a gore fills the wedge, and its rails go straight on across to the main track's rails. - **A level crossing** is a road across the track: an ordinary junction, with the rails kept across it. - **Get Switches** lists the switches, each with its place, how many ways it has and the one it is set to, the leftmost being 0. **Set Switch** sets one on the server and reaches the clients; **Find Switch** gives the one nearest a place. A setting is kept by the switch's place, so it survives the network rebuilding. - **Find Track Position** gives a place on the track nearest a location, **Move Along Track** moves it any distance, forward or back, through the switches by their settings and over the level crossings, and says when the track ended. **Get Track Transform** turns it into a location and a facing. A train is one position per axle moved every frame. The rail lanes are in **Get Lanes** too, as type Rail, but a train reads them both ways, so follow the track with the three calls above and not with Next Lanes. Lanes are numbered again when the network rebuilds: find the position again then. The rails have no collision and the plugin has no train. Past a switch the branch's rails are straight, so the track turns the switch's angle at once where they meet: keep it shallow. ## Pipes A **Splinecraft Pipe** is a spline whose points are corners, each turned with an elbow 1.5 times the pipe's size. The spline point's Scale Y sets the size from that point on, with a cone where it changes. Round or rectangular (a duct, kept level through the bends). Flanges go on both sides of each elbow and reducer and every 6 m of straight pipe; free ends are open, capped or flanged. A pipe ending on another's straight run makes a tee, two ending at the same point a cross, two ends together a coupling. **Supports** every 4 m look for the nearest floor, ceiling or wall within 3 m and make a clamp, a rod and a plate. A profile can use your **kit** of static meshes instead: straight, elbows, tee, cap and flange, with sockets `In`, `Out` and `Branch` at their openings. The plugin's own kit is in `/Splinecraft/Kit`. ## Cables A **Splinecraft Cable** hangs between the points of its spline, each span as a catenary: by **Slack** (percent longer than the straight line), by **Sag** (drop at the middle) or by **Tension** and weight, like a power line. It is a tube or a **chain** of links. The plugin's cable material sways each span in the wind by how much it may move (nothing at the ends); any material reading UV channel 1 can do the same. A point can be held by another actor, at a socket or bone or at its root, with an offset (`Attach Point To`). In the editor the cable follows when you move the actor; in the game call **Rebuild Cable**, or simulate it. ### Physics Tick **Physics > Simulate** and the cable becomes a rope in the game, starting at rest in its hanging shape, so it never stretches or snaps on the first frame: - **Free End** lets the last point hang, like a rope down a wall. - It rests on the world and on other cables, and pawns and physics bodies push it aside. Held points follow their actors. A rope with more slack than the height it hangs from starts lying on the ground, or over what is under it, not through it. - **Cut At** cuts it, **Reel** lets it out or pulls it in at the reel speed, **Add Impulse** pushes it, and **Break Stretch Percent** has the server cut it where it is pulled too far. - **Pull Held Bodies** (on by default) makes a taut rope pull the physics bodies that hold its points. Attach an end to a crate with **Attach Point To** and the crate hangs from the rope; **Reel** a negative length and the rope lifts it like a winch; attach each end to a vehicle and one tows the other, each slowed by the other's mass. A rope bent over an edge pulls round the edge. The server does the pulling and the bodies reach the clients by their own movement replication, so set them to replicate. **Get Tension Newtons** reads the pull, 980 N for 100 kg hanging still. A spline point between the two ends is held to the world, so a tow rope has two points and its length comes from **Slack Percent**. - It sleeps when nothing has moved for a second and wakes when a held point moves, something comes near, or it is cut, reeled or pushed. - Each machine simulates it from the same start, anchors, cuts and length, so it looks the same everywhere without sending its points. Simulated cables don't block and are not baked. ## Routing a pipe or a wire by itself **Route Pipe** and **Route Cable** take a start and an end and lay the pipe or the cable round what is in between, with square bends: connecting two machines is one call. **Find Route** gives only the corners, to preview a route or to lay something of your own along it. - The route keeps **Clearance Cm** from walls and from anything else that blocks, and a bend costs **Turn Cost Cm** of length, so it prefers long straight runs. A pipe widens the clearance and the grid to fit its own size. - **Allow Diagonals** adds 45 degree runs. - It looks no farther than **Margin Cm** past the box around the two ends and gives up after **Max Steps** places, returning nothing. Round a 10 m wall it takes 16 ms. - The start and the end may touch what they connect: leaving the start and reaching the end are never blocked. Put the two machines in **Ignored Actors** when the route should pass close to them. It works in the editor and in the game. On the server, what it lays reaches the clients like any other pipe or cable. The route does not look for a wall to follow; supports still find the surface under the pipe by themselves. ## What is joined to what: the line graph **Get Line Graph** gives the game every pipe and every cable of the level as networks, the way **Get Lanes** gives the roads to traffic. A network is the pipes, or the cables, joined to each other. Pipes join where the plugin joined them with a tee, a cross or a coupling. Cables join where a point of one is within 30 cm of a point of another, or where the same actor holds both. - **Are Connected**, **Get Connected Lines**, **Get Network Id** and **Get Networks** answer what is joined to what. - **Set Carrying** on a pipe or a cable shuts it: the network splits there, like a shut valve or a switch turned off. A cut cable carries nothing. - Add a **Splinecraft Connector** component to a pump, a tank, a generator or a lamp, at the end of a pipe or on a cable's point (or let the cable hold the actor). Its **Supply** gives to the network, a negative Supply takes. **Is Supplied** is true while the network gives something and at least as much as is taken, **Is Connected To** says whether two connectors share a network, and **On Network Changed** fires when any of that changes. - A connector touching two pipes, or two cables, joins them while it carries. Put one in the gap between two pipe ends and **Set Carrying** on it is a valve. Every machine works the graph out from the pipes and cables it has, so clients read the same networks as the server. Supply and Carrying replicate with the connector's actor. The graph rebuilds a moment after anything changes; ask **Request Rebuild** after you move a connector. Network ids are only for comparing: they change when the graph rebuilds. The graph counts and compares, it does not simulate flow: no pressure drop along a pipe, no direction. ## Drawing in the viewport The **Splinecraft** mode draws roads, pipes or cables, with a profile for each. Pipes sit 50 cm over what the click hits and cables 600 cm, both adjustable; **Straight Segments** gives sharp corners. A blue line runs from the last point to where the next would go. The same drawing is in Blueprint and Python as `SPC Drawing`. The panel also has **Check Setup**, **Import Open Street Map File** and **Export Lanes To ZoneGraph**. ## Traffic data `Get Road Network` gives the network of a world: | | | |---|---| | `Get Lanes` | Every lane as points in the direction of travel, with width, speed, type, road, junction, the lanes it leads to and comes from, whether it gives way, and the signal phase it waits for | | `Get Junctions` | Location, arms, roads, outline, roundabout, signal phases and their times | | `Get Signal State (Junction, Phase)` | Off, green, yellow or red now; `Get Signal State At` for any time | | `Get Crosswalks` | Curb to curb across the road, width, junction and the phase of the road crossed (people walk while it is red) | | `Find Nearest Lane`, `Is On Road`, `Create Road Mask` | For AI, scattering and decals | | `On Network Rebuilt` | Called after every rebuild | A road's `Get Stop Lines` gives where its traffic stops or gives way. ## PCG - **Splinecraft Road Filter** keeps the points off the roads and junctions (or only those on them), with a margin. Only road on the ground counts: the terrain under a bridge and over a tunnel stays free. - **Splinecraft Lanes** gives a spline per traffic lane, in the way traffic goes, tagged `Splinecraft_Lane` (and `Splinecraft_Junction` inside junctions). The roads' own splines can be sampled with PCG's **Get Spline Data** as with any spline actor. ## ZoneGraph **Export Lanes To ZoneGraph** puts every traffic lane into ZoneGraph for Mass traffic and crowds: one spline zone shape per lane, on an actor named Splinecraft ZoneGraph that each export makes again. The shapes meet where the lanes meet, so ZoneGraph links them through the junctions. They use the lane profile **Splinecraft Lane**, which the first export adds to the project's ZoneGraph settings. Export again after changing the roads. ## Generating a road network Drop a **Splinecraft Road Generator** in the level, pick a layout and press **Generate**: it lays a whole network of roads from a seed, centered on the actor and turned with it. The junctions, the lanes and the terrain come from the road network, as with roads you draw. - **Grid** is straight streets crossing square, **Radial** is rings round the center with streets running out from the first ring (more start farther out where they spread apart), **Organic** is a grid whose streets wander. - **Size Meters** and **Block Meters** set how big and how dense. Every **Main Road Every** streets one uses the **Main Profile**, like the outer ones; the rest use the **Street Profile**. - **Irregularity** moves streets off their places, ends some at a cross street (a T) and leaves some out. 0 lays every street. - **Follow Ground** puts each point on what is under it, so the network follows the landscape and the roads cut, fill, bridge and tunnel as usual. - The same **Seed** lays the same roads. **Generate** replaces what it laid before, **Clear** removes it, and the roads are ordinary roads you can edit afterwards. It works in the game too: spawn the generator on the server, set it and call **Generate**. The roads reach the clients like any other. ## OpenStreetMap **Import Open Street Map File** (or `Import Osm File` in Blueprint) reads a `.osm` file as openstreetmap.org exports it and makes a road per street: - the pieces OSM splits a street into are joined back where it goes on straight; - the profile comes from the street's kind (motorway down to service) and its `lanes`, `oneway` and `maxspeed` tags; one-way streets mapped against their way are turned round; - every point is set on the terrain under it, and the middle of the map goes to the origin you give; - footways, paths and cycleways come in only when asked, as narrow paths without junctions. ## Check Setup **Check Setup** (on the mode's panel, and on every road and pipe) lists in the Message Log what will not work or look right: curves tighter than the profile's minimum, folded road edges, lanes without a material, props without a mesh, roads off the landscape, bridges with less than 4.5 m under them, junctions on a roundabout too close together, a landscape material that can't open tunnels, what roads spawned in the game need from the landscape, kit pieces without their sockets, supports with nothing to hold on to, wires without poles, and cables held by an actor or socket that is gone. ## Limits - Traffic drives on the right by default; lane directions in the profile make left-hand traffic. - Landscape grass and the navigation mesh are not updated when a road is spawned in the game. - Ramps join only the outermost lane going their way. - The road's own collision is complex (the mesh); there is no simple collision. ## Credits The road surface textures are CC0, from [Poly Haven](https://polyhaven.com): Clean Asphalt, Concrete Pavement, Tarred Gravel and Dirt Floor.