How can I let an actor snap to a spline path?

Hello,
I’m currently working on a system to draw a spline during gameplay to build walls or other useful stuff. The script is basically an Actor with a Spline Component. When you spawn the Actor a single Static Mesh gets added and the whole BP follows the cursor. When you press the left mouse button it stops following and the second spline point follows the cursor. This way you can click to draw straight lines. When you hold the mouse button you can also draw along a path.

Then I’m constantly checking the length of the spline and spawn static meshes along it. I’m not using spline meshes since I don’t want any deformation. This animation shows how it works in-game:

I use a function to determine how many meshes I need and another one to move those meshes on the spline. This screenshot shows how the meshes are being moved (to the right is just some stuff to check for collisions with other Actors)

This is what I have and now my actual problem:

  1. When I’m done drawing one spline I want to be able to spawn a second one. This second one will be stuck to the mouse cursor just like the first, but when it hits one of the meshes from the first I want it to snap to the closest point on the spline. When I move my move close enough to the spline it should follow the mouse but stay on the spline, only when the mouse gets further away it should follow the cursor again. I am just using the spline to calculate the world location for each mesh so I have no idea how I would get a reference to the spline itself when I hit one of the meshes. I think this would be fairly easy if I could just check for an overlap event with the blueprint that contains the spline but only the meshes have collision and not the spline.

  2. If it is actually too complicated to get a reference to the spline when hitting one of the meshes, it would probably be enough to snap to the nearest mesh or something like that also.

I do have some ideas how to achieve this snapping feature but none have worked out so far. I have no working solution implemented so far, so any idea would be greatly appreciated.

I believe it isn’t possible in Blueprints yet however in c++ you could definitly do it