rdSplineTools Tutorial 2.2 – Snapping Spline points to Mesh Sockets

Another tool in rdSplineTools is the “Snap to Socket” tool. When dragging control points in your spline, when your point is dragged close to any socket in your spline meshes for any close spline actors, it will snap to it. If you hold down “z” and “x” at the same time while dragging – instead of using the default snap code it calls a custom Blueprint function which you’re in charge of implementing.

This tutorial explores both types:


Step 1. Create two StaticMeshes for your Splines with sockets on them.

For this tutorial I’m using two of the Road meshes from my Road pack (the 2 lane and 6 lane). They have sockets along the ends to match up with the various meshes with different numbers of lanes along with sockets for snapping other roads as intersections.

Any meshes you intend to use with your splines are OK, just add the sockets from the StaticMesh Editor:

Call the Lane sockets “XLaneY” where X=the Lane type it’s for and Y a unique number.

For the Intersections, call them “Intersection Left” and “Intersection Right” – rdSplineTools uses those names to work out which way to rotate the dragging points tangent.


Step 2. Set up some Splines Using our Socketed Mesh.

Add 4 splines to your level with your Spline Blueprint (or use the one from Tutorial 5) and set it to use the mesh that you’ve added some sockets to (here I’m using the 2 lane road). Make two of the roads positioned to be avenues between the other two roads.


Step 3. “New Spline Here” from the rdSplineTools section of the Spline Menu.

Create a new Spline for our second road with the “New Spline Here” tool:


Step 4. Drag the start point of the new Spline while holding Z near your sockets.

Right, that’s it – now when you drag the spline point while holding “z” it snaps to where the sockets are on the mesh.


Step 5. Add a new Function to your Spline Blueprint.

Now we’re going add a custom function to the blueprint where we can control where the point snaps to when both “z” and “x” are held down while dragging. (make sure in and out parameters are exact and “Call in Editor” is ticked)

The Function is called “rdGetClosestSocket” – make sure no spaces or capitalization is done by the editor. Make it have 3 float inputs and 3 float outputs.

When this function returns 0,0,0 – it means no socket was found – when it returns non-zero values for at least one it will snap to that.


Step 6. Test by holding z and x while dragging the Spline point.

When dragging the new spline point now, you’ll see logging on screen with the passed in values.