SplineComponents in 4.9r4 are not editable when created in construction script with code

“AllowSplineEditingPerInstance is deprecated as it was confusing some users - now the default is that all splines are editable, unless the component is in a Blueprint whose User Construction Script sets the spline up itself. In this case, the spline is visualized in a ‘read only’ mode.”

I create a spline component in c++ and it becomes inherited within a blueprint made from the source file. At which point in 4.9r4 it becomes read-only. This means no tweaking can be done after that point.

If this remains the case I believe the procedural nature and usage of splines will be destroyed in situations where post-construction script changes need to be made. Is it possible there is a switch we can use to enable the editability of the splines made with c++ in the construction script?

Hi Doublezer0,

Spline Components become uneditable by the visualizer, when they have been initialized by the construction script, for consistency with other types of properties. You’ll notice that if a construction script changes any property of a Blueprint component, that property is then greyed out in the details panel. The same is true of the Spline Component - if you have a construction script which is initializing the points itself, they cannot then be changed by the visualizer. Essentially the construction script has the ‘last word’ on the initialization of the spline, or indeed any component property.

What is your construction script doing and why do you wish to override it with the visualizer?

in 4.8 I would load up some data to build a spline in a c++ file. Essentially the source file contains the functions and some variables for use within blueprints. I then create a blueprint from the source. In the construction script I call various functions to get data, create spline, create spline points. However the script only builds a general guideline spline. It will have to be edited after to adjust for the level or make specific changes that affect gameplay.
The flow goes like this.
Code → create blueprint → load data → create spline/points → add meshes → fine-tune spline points (location, rotation, tangents).
Without the fine tuning the meshes will never look right.

Hi Doublezer0,

Unfortunately what you wish to do isn’t really supported by the engine. In general, the engine adheres to the philosophy that the User Construction Script is not a set up step that can then be customized on a per-instance basis. To support that would cause confusion and fighting over the ownership of properties (the instance overrides vs the archetype blueprint). As you can see, any component property changed by a Blueprint’s Construction Script becomes read-only, and splines were brought into line with this in 4.9.

Perhaps what is needed is some kind of utility which relinquishes control of an actor from the blueprint to the instance, although this of course means that any changes made to the original implementation (the archetype) wouldn’t apply any longer. If Bluefabs find their way back on to the roadmap soon, this may be the solution you need.

Sorry not to be able to bring you better news. This is an area which is constantly evolving to meet users’ needs, and I will certainly put forward your use-case as an example of why we may need to modify our model a little.

This is most disappointing and has wasted a lot of my time where I earned not a single penny. Something I was banking on with a marketplace release. It seems like a terrible decision to have destroyed a method that was open and available to anyone who wanted to use it in 4.8 only to then take it away in some kind of “yeah it wasn’t meant to do that” scenario. Excuse my complaint but I worked extremely hard on this and I have to scrap a project that was really exciting that I spent hundreds of hours working on.

I’m confused by this… so now, if you set a value to anything in the Construction Script, you can’t change it for the rest of the game, so that Var can ONLY be changed in the Construction Script?

If so, that’s a pretty silly change…

I think this probably needs some clarification.

The intention of Construction Scripts was that they could take properties as set in the Details Panel and manipulate the object dynamically based on them. The Construction Script is run repeatedly (every time an Actor is moved or a property is changed, for example) so that it can dynamically respond to the properties and environment.

Imagine we have a Blueprint with a Box Collision Component, with the following Construction Script:

59003-ucs.png

Every time the Construction Script is run, it will set the extents of the Box Collision Component to the value specified. If you were to edit an instance’s box extents, they would be obliterated again by the Construction Script as soon as it was rerun (e.g. by moving the actor or setting another property). So, to protect against that possibility, the property is made read-only in the Details Panel for the Box Collision Component.

Suppose you wanted to be able to edit the box extents while constructing them with a default of (100, 100, 100). In this case, the way to do this would be to expose a Vector variable defaulting to (100, 100, 100) and use this as an input to the Set Box Extent node. This is a very simple case, but it demonstrates that the Construction Script is essentially the ‘owner’ of this property. It’s a good thing that the component property becomes read-only as changes to it would easily get lost upon rerunning the Construction Script.

OK, back to Splines. I appreciate that this is a far more complicated case. In general I would say that the same philosophy should apply: if you are leveraging a Construction Script to set points on the spline, then this isn’t strictly compatible with editing those points per-instance. When the Construction Script is run, these points would get lost. So we need to be able to specify whether to allow the Construction Script to make changes to the per-instance points or not. This is essentially what was removed in 4.9 (the ‘Allow Spline Editing Per Instance’ flag). It still exists but in a read-only form (the ‘Spline Has Been Edited’ flag).

I agree that we need some way of allowing this kind of thing to be done and I will be requesting that we work on this a little more for the next release. Meanwhile, you can make a simple local change in order to get this functionality back,

In UE4\Engine\Source\Runtime\Engine\Classes\Components\SplineComponent.h, find the following lines:

	/** Whether the spline has been edited from its default by the spline component visualizer */
	UPROPERTY(VisibleAnywhere, Category = Spline)
	bool bSplineHasBeenEdited;

and replace them with the following:

	/** Whether the spline has been edited from its default by the spline component visualizer */
	UPROPERTY(EditAnywhere, Category = Spline, meta=(DisplayName="Override Construction Script"))
	bool bSplineHasBeenEdited;

When your construction script has set up the points, you should be able to tick this box in the component’s details panel, and the points will then be editable as normal, while changes to the points from the Construction Script will be ignored. In order to reset the points to the Construction Script’s defaults, you can right-click on the spline and select “Reset to Default”. I hope this is a reasonable solution. I will see if we can clarify this feature design-wise for the next release.

That is awesome thank you ! I am going to try this out and I will report back.

I tried this but it still did not return the points to editable in the vizualiser. They remained pink tinted and un-selectable. The option was only shown under the spline component detail panel and was greyed out. It could not be checked. I also tried adding it to my extended spline comp class to over-ride where I found the variable had moved from the actual spline component to a new category of “Spline”. This checkbox was not greyed out but had no effect on the read-only status of the spline points.

That’s strange, I can’t reproduce that. My test is:

  • Create an Actor blueprint with a Spline Component
  • Add the following construction script:

59156-splineconstructionscript.png

  • Place an instance. Spline will be pink (read-only) on selection.
  • Go to Spline component in Details panel and tick ‘Override Construction Script’. Checkbox now becomes greyed out.
  • Spline now turns white and is editable.
  • Right click on spline and select “Reset to Default”, and the construction script will rerun and the spline turns pink.

Could you send a Blueprint which exhibits the problem? Or explain in more detail your setup along with a fairly comprehensive set of instructions for reproducing this myself? Once I can reproduce the issue, I’ll be able to roll out a solution as soon as possible.

I followed your steps to the letter and still have the same problem of the spline being pink and read-only. I added the c++ change to the SplineComponent.h then

  1. Added an actor BP with a spline component hooked up with the construction script the same way as you did. The checkbox is greyed out.

  1. I unplugged the construction script and found the checkbox was checked but greyed out this time when I added an instance.

The main thing that differs in this from my project is that I create the spline, spline points, meshes and all functions and data storgage in c++ and create a Blueprint from the source where I wire up the logic flow in the construction script. I can send you the source and blueprint file if you wish but it is the same issue as with this simple example you gave.

Thanks for the screengrabs, I’ll take a look into this first thing tomorrow. One thought is if you’re using C++ to initialize the spline component, you may find that you need to add a SplineComponent->bSplineHasBeenEdited = true in your code after setting the points if you would like it to remain editable in the editor viewport. Without seeing your C++ code, I can’t be sure if this is the case but it would be worth trying. If you like, send me a PM on the forums and we can arrange to exchange some source files in private.

Happy to hear it! If you have any other problems, please give us a shout :slight_smile:

That did it ! Thank you so much for your help. I would marry you but I am married to my work :slight_smile: