So i have this Blueprint Actor which is in actuality like a sort of Wrapper for a Data Structure. The blueprint only has events and functions that allow a controlled use of the data structure (ex: get text, move index, etc.)
It is kind of a hack since the actual data is the default values of a variable of the Data Structure (literally a struct object) that i put in said Blueprint actor.
Thing is, i realized that i want this functionality to never get unloaded or its state reset each time we use a level transition, so the Game Instance has to use it, but i do not know if we can use the first level blueprint to get the instance of the blueprint actor, send it to the GI so it can set it’s actor instance variable to it, and expect the variable to not lose it’s reference when we load another level. Is there a more simple way to get the actor directly instantiated in the Game Instance?
I don’t think it’s possible, unless you use streaming levels system.
The thing is, actors are attached to World, which is usually the level, so it can’t persist without it.
Game Instance is an Object (parent class of an Actor) so it has no World connection, that’s why it can persist between levels.
If you use Streaming Levels, then you can add your Actor to Persistent level which is never unloaded and your Actor never will as well.
If you switch levels with “Open Level” node, then I would try to convert my actor to a base Object and spawn it on begin play of Game Instance. I think - but I’m not sure! - if you set Outer of the new object to Game Instance it will stay alive until you destroy the game instance.
I have looked into it and it seems to work, The persistent level is just composed of invisible actors while the sublevels handle the rest of the visuals, neat!