My array in the editor doesn't get saved

Hello :slight_smile:,

I have an array in my blueprint, which gets populated when I start a custom event in the editor. I’ve set the checkbox “Call in Editor” of this event to true, so I can start it in the editor, when the game is not running.

This works great, but everytime I close Unreal Engine and open it again later, every array, I have filled through my custom event, is like it was before I have pressed the button (empty or filled with other entries, I’ve set manually).

I always save my level (by clicking on File > Save current level), but it seems like everything, I don’t set manually, gets resetted to default when I reopen the level again.

Any ideas, why this happens?

Thank you in advance!

I’m assuming the BP actor is in the level you’re saving?

@ClockworkOcean Yes, sure :slight_smile: It is part of the level.

I have a theory, but I’m not quite sure:
Maybe it is has something to do with the loading of the blueprint actors.

When the level gets loaded and tries to load all the blueprint actors with it, maybe some of the blueprint actors are not loaded in the moment, it tries to get them for the array?

Example:

I have my BP_Array actor and multiple BP_Item actors in my level.

Let’s say, the BP_Array has BP_Item1, BP_Item2, (…) until BP_Item9 in it.
But at the moment, BP_Array is loaded, BP_Item2 is missing, but it would get loaded after it. Maybe, it gets skipped and is then not part of the array afterwards.

Is that possible and how to prevent that?

1 Like

Your example should work.

Can you show your custom event?

I just made this array BP

I clicked the event, stored 45 actors. Saved the level.

Restarted the editor, there’s still 45 in there.

Thats exactly how my array is done:

My workaround at the moment is, to do it in construction script. That works, but it feels unneccessary, to construct it all the time.

1 Like

I just did it with a list of BPs, and it worked also.

Are you using world partition in the level?

Apart from that, I have no idea, I’m afraid… :melting_face:

1 Like

Not sure what is going on in your case however things i found out:

  • call in editor (also editor tools, events that can be triggered from editor, etc) those always run from default values, save to variables, however after code is done everything is back to defaults. Those spawn instance of blueprint do their thing and kill that instance (also erase all variables)
  • there is also big problem of loading order in unreal, (just print to log events when everything is loaded) so you know what loads after what
  • do not use level blueprint unless you really need to, it is better to make actor run code inside of it, and then place such actor in level.
  • another big pr0oblem with unreal is making network of references, if you use reference to anything else, it will be loaded, in case of using level blueprint everything you reference in it will be permanently loaded with that level

So good places to store variables are things like game instance (however this loads very early, so it cannot find actors in levels player character etc,), game mode is also nice, but with multiplayer you need to watch what is server and what is client side.

Recently i had idea to use Json for storing default (Startup) values for my game. It turns out that json text file is not packaged with project, so back to data tables or data assets for me. Lesson from that: package your project like weekly, and check if all works same as in editor.

ps.
Data assets are great (with really simple C++ to declare them), however for some reason they are not always loaded, so until this mistery is solved i am not using them.

1 Like

Tell me if you get anywhere with this :slight_smile:

1 Like

Yes, I am using World Partition, but every actor involved in the current problem has the “Is spatially loaded” checkbox set to false, to prevent that it isn’t there when it is needed.

1 Like

Thank you for your many ideas/approaches. I am not that expirienced (+ only work with blueprints, no c++), so I didn’t understand everything you recommended at first glance :wink:

Maybe let me explain first what I am trying to achieve, maybe there is a much better way. Because what I read in your comment is “Everything with data can be a little unreliable in Unreal Engine sometimes”

What is my goal
I have a lot of information, which is tied to a specific int value.
When my int is 0, there is a set of strings, ints, sound waves, but also some actors in my level, which are relevant then. The same for 1 and 2, 3, 4 … and so on. Think of it as a route/waypoint system. When the actor is at waypoint 2, he needs specific information, on waypoint 3 it is different information. Please keep in mind, that there are multiple actors who are on different waypoints at the same time. So, there is no global “current waypoint”, but a current waypoint for every actor instead.

What I do at the moment
I have a data table with all information needed for that specific waypoint. But as mentioned above, some of that data are references to other actors in the level, which cannot be stored in a data table unfortunately (or I didn’t found a way to do that). So, in addition, I have some arrays which store these other actors at the same position (array index == data table row).
And these arrays are my current problem, because they get resetted all the time and I don’t know why.

Your topics: Call in editor
When I read it correctly, you say, that these call in editor things erase the variables, they have filled before. Maybe this is my problem, but then I also don’t understand, what they are for in the first place :smiley:

Your topics: Loading in order
You mean, I give every blueprint involved a print string node to see, in which order it has loaded? I am little afraid, that these loading orders maybe change later, so when I fix it now in any way, the order could change later on and I have the same problem again. Is this possible?

Your topics: Level blueprint
I do use it, but only at one place and only to debug stuff, not for the final game. But this is not connected to my current arrays and/or blueprint actors inside these arrays.

Your topics: Network references
Fortunately, this game is not meant to work anywhere else outside of my local computer. So, when I understand you correctly, this is only important for a multiplayer game, which it isn’t :slight_smile:

Your topics: Others
Your idea with the game instance or game mode let me thought about, if I really need multiple actors for what I want to store. Maybe it is easier to just have one big “data game mode blueprint” which has all the data inside it. So there is no need to reference between different things.

I would also love to store everything in a file such as json, to be in control of the data and don’t need to trust Unreal Engine with it. Sad to hear, that it doesn’t work.

Thanks again and maybe you have another hint for my specific situation :slight_smile:

That may be due to multiple reasons:

  • actors in unreal during runtime are allocated in memory objects, and then there you have one object allocated by editor, and source code/object. So it is quite possible that each of your actors has separate copy of that table, ie. it keeps different values for each object/actor. Solution to this is to keep that array in single actor like game mode. Or create master of that data actor, and place only one in level. Then all other actors can get all actor of class, and access it. For world partition make sure that actor is always loaded.

  • you may have that run in editor turned on somewhere, so that actor is loaded, then created every time you try to access that table, ie. each time you try it you get new / fresh copy of it.

For simple waypoint system, you can flip whole data:

  • create variable/actor that keeps all waypoints, lets call it bp_waypoint_database
  • use actor to ask (call waypoint database) and use function that does: “hey i am at waypoint x, what is my next waypoint?”
  • this way each actor remembers its own state. and you have all logic in single actor and single code place
  • state information - this you can either keep in bp_waypoint_database, or in each actor. I would recommend keeping it in each actor. This way you can use inheritance and mutate actor behaviors. So create base actor that communicates, then make child classes that implement different sets of behavior.
1 Like

Thank you very much :slight_smile:

I will try to make that single database actor and come back here, when I’m done and can tell, if it works (this will take a while, I expect).

I think i need to explain it a bit more:

  • that single database for waypoints, should be only to code (store) order of waypoints or which one connects where
  • base actor should have communication with database, and some common logic
  • then child actors (inherited from base actor) should have logic for different types of behavior.

Also you should look into data assets, those (probably) are best data structure for this task. However they do need C++ as data asset struct can be only declared in c++. But there is no need for C++ code besides declaration, and that is really simple.

1 Like

My first approach seems to work (I’ll explain at the end), but I observed one strange behavior of Unreal Engine, which maybe has something to do why there are problems with saving the state in the first place:

I made some Data Assets, which store relevant data. These data assets are all in arrays in one big blueprint actor now, so there should be no problems, finding each other.
When I change the content of one of these data assets manually by clicking inside it in the editor and change something, a star symbol appears next to the name of the data asset and the editor knows, that there is something unsaved:
system-not-detecting-change
When I press “CTRL + S” or “CTRL + SHIFT + S”, everything gets saved.

But when I do the change by a “Call in editor” button, Unreal does not know, that there happened a change - there is no star and also the text in the status bar at the bottom right says “All saved”:
all-saved

It seems like Unreal Engine doesn’t count the automated change as a change at all. So I need to manually save it and have no feedback at all, that this saving has worked.


My approach at the moment:
I have one BP actor, from which one instance really spawns in the game (invisible).
Inside this BP actor, there are different arrays which are referencing data assets or actors in the level.
Some of these data assets references other data assets again.
This seem to work.

To make more clear, what I really do (maybe this helps in understanding if my approach is good and also, if it is what you have suggested):
My game is a network of many subway trains. Each train needs to know, where in the route it is at the moment (= an integer variable) and also, what it needs to know at this position (what signals are affected, what switches must be set in which direction, what station should be displayed in the train and so on). All information, which is not tied to any actor or doesn’t need to get automatically inserted in the data table, can be placed here. But all the other information (actors like trains, stations and so, but also everything which should be automatically inserted based on some logic) must be kept somewhere outside. And this is the new BP actor.