Here we go:
Source code + blueprint diagrams: (2.5MB)
is a C++ engine extension of UE4’s built-in SplineComponent and SplineComponentVisualizer, with additional support for arbitrary rotation (eg. twisting, looping) and width/scale at each spline point.
Look for the “// BEGIN SDS” and “// END SDS” markers in the C++ code to see what I’ve added.
At some point I’ll get around to cleaning up and submitting a pull request to the engine mainline, but for now here it is to play around with - get your hands dirty!
I’d recommend watching 's tutorials as you’ll want to implement a similar road spline blueprint class, replacing SplineComponent with RoadSplineComponent.
I’ve included my own blueprint class construction script for reference as a PNG in the ZIP. Use to create roads that fit along the road spline. You’ll need to set up your Tiles array with static meshes for different road tiles, and populate your Tile Indices array to specify which mesh each road segment should use.
BP_RoadSplineActor variables (and sensible defaults):
Spacing: 2000. Distance in world units along spline between each road track segment. Each segment is one SplineMeshComponent instance.
Tangent scale: 2000. Changes how the road will be deformed between spline points. Generally you always want to equal Spacing for best results.
TrackWidthScale: 0.002. Scalar to align static mesh widths with the spline width.
Create Segments: Boolean to toggle the spline meshes on/off.
Spline editing controls:
Same as SplineComponent, except the rotation + scale gizmos work.
Hold Alt to drag out a new spline point.
Scaling the X axis controls the tangent.
Scaling the Y/Z axes controls the spline width.