Dynamically created Spline Components manually edited in viewport cannot be read by Construction Script

In a Blueprint script I am working on, I create spline components dynamically using the Add Spline Component node in the construction script. From there, the user is able to manually modify the points/tangents of these spline components per instance within the editor viewport. However, those positions/tangents set manually are not able to be read back by the construction script.

An example of how I am looking to use this: In my Blueprint, spline mesh components are created within the construction script to span between each segment of two points along the spline component. When I attempt to set the start/end point positions/tangents of the spline mesh segments, they do not deform to match the spline. This is because the construction script is unable to read from the locations visualized in the viewport after the user has manually modified the spline component’s points.

Although the toggles within the spline component details to “Override Construction Script” and “Input Spline Points to Construction Script” seem as if they might affect the outcome of this, nothing seems to feed data from the visualized spline in the editor back to the construction script. As a note, spline components added manually to the Blueprint actor, rather than using the Add Spline Component node within the construction script, of course do not have this issue because they are created before the construction script runs, rather than during.

Right now, I am able to do a sort of workaround by adding editable Transform variables within an array, with Show 3D Widget enabled so it can be positioned manually in the editor. The transform points in the array define each point of a spline. Then, a dynamically created spline component is set to the points of its corresponding transform within the construction script. So, the transform widgets are edited within the viewport, rather than the spline component itself. It works, but it is quite a bit more cumbersome to work with. Ideally, it’d be great to be able to use the spline component controls in editor, especially for controlling and visualizing the tangents.

As far as I am aware, this is not a new issue to 4.12, and previously splines created in the construction script were not even able to be manually edited in the viewport, let alone have those values be read back within the construction script. I understand why this issue is tricky, but I am curious to hear from others if this is something in progress/feasible, or if it is a feature that is just not possible.

I assume your actor’s class is a native c++ and not made into blueprint and that you create the spline mesh in your OnConstruction function override, if it is then that’s the reason because your code was not being run when the spline changed.

So what happened was when the spline component was modified (FSplineComponentVisualizer::NotifyComponentModified) it called the owning actor’s PostEditMove, this function will only re-run construction script if the actor’s class is generated from blueprint:

	if ( ReregisterComponentsWhenModified() )
	{
		UBlueprint* Blueprint = Cast<UBlueprint>(GetClass()->ClassGeneratedBy);
		if(Blueprint && (Blueprint->bRunConstructionScriptOnDrag || bFinished) && !FLevelUtils::IsMovingLevel() )
		{
			FNavigationLockContext NavLock(GetWorld(), ENavigationLockReason::AllowUnregister);
			RerunConstructionScripts();
		}
	}

There are two ways to solve your problem, 1. Make a blueprint whose parent is your actor class, 2. Add your spline mesh component setup in PostEditMove. Which one you want to choose depends on your game really, if you don’t want to expose things to whoever is using the editor then you may want to go with the second option but I personally prefer the first option because setting up the visual representation of a spline mesh should be exposed to someone who have artistic sense or know the art direction of the game (and I surely don’t want to do that as a programmer).

Hello! Any luck solving this in Blueprints?

Unfortunately, no. Using the latest release, 4.15, and it seems that this still isn’t possible in Blueprints. I’m still using a workaround by adding Transforms to an array with the 3D widget enabled, so the user can drag those around in order to set individual points of a spline manually based on them. But, it’s not ideal and it would be cleaner to just manipulate splines themselves.

Since Transforms are able to do this (set a custom location in the viewport by moving the 3D widget and their positions are able to be read from the construction script) it seems like splines should also be capable of this, but maybe I am thinking about it too simply.

Well, in my case I can’t use that workaround since I’m generating spline points in construction script (so they could be altered after generation, just like it’s possible with non-dynamically-added spline component)… I’ll try to figure out something else. Thanks for the answer!