Construction script clears blueprint variables

Simplified version of the problem.

I have a cylinder component and vector position variable with the widget set.

My custom ( run in editor ) event ‘Init’ point the variable at the cylinder and puts the location ( 0,0,0 ) in the variable.

WHY - when I then move the BP ( and the construction script runs ), does my reference to the cylinder get trashed?

( end of GIF notice the mesh name gets replaced with TRASH ).

302506-construct.gif

Init event:

Construct:

All components created in editor during construction (before begin play) get destroyed whenever construction script re-runs. This includes any arrays made during construction (via MakeArray). You have to re-create your component in Constvruction script. You could put your init there.

1 Like

You can set your variable “Location” to bInstanceEditable = true, this ensures that the value is not reseted after you rerun the construction script.

I just tried it and in my case, even if the variable is Instance Editable and/or SaveGame it still gets reset to default value whenever Construction script runs (UE 5.0).

Find any way to pervent this?
im creating a bunch of collison boxes with a widget as child in construction script and changing their location by hand all okay until i move the bp itself or change any variable and than every box will reset to spawn location which is zero and i have to redo again.

I did “little dirty hack” for this problem:

  • i use Data Assets and save those variables to new DA. Then delete them obsolete ones manually.

Lolz again necropost trap! :stuck_out_tongue:

2 Likes

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.