Download

Variables in a BP's Construction Script don't get saved along with the level

[EDIT: SOLVED!] The BPs that the construction script looks at need to be in the exact same level as the BP in question - not in a sublevel for example. The editor gives you a warning when you try to assign something like that manually, however a construction script doesn’t give any errors, however still technically works, but only when moved in the editor.

*I have a construction script in a BP that looks for other BPs placed within a level, populates, rearranges some arrays and then feeds that to a struct (that is used later elsewhere).

I have this in the construction script because the only time I need this code to execute is when I’m designing a level (they’re “waypoints” - objects that tell my pawn where to teleport). So it makes sense to have this “prepopulated” using the construction script.

This script works like a charm and does its thing as expected (updates the arrays and the struct). In one level it also saves properly - meaning that when I save the level, the exposed variables of this BP save with it, so there’s no need to do anything else (it works in a built game as well).
However in a different level with a different BP (but with the exact same logic) - it doesn’t save when I save the level. The construction script certainly does its thing works when clicking or moving the BP, but it looks like it doesn’t get activated on level load - therefore not working in the built game (as one would expect).

In the meantime I’ve moved the code elsewhere and adjusted it so it goes off after beginplay, so problem solved. But I’m still curious if anyone has suggestions why it works in one level yet it doesn’t in another, seemingly at random?!

I’ve also tried using a different struct, thinking that it somehow conflicts within the editor or sth like that, but the result was exactly the same.*