Access violation on C++ variable, set in BP

Can’t you get the PersistentLevel and ALL Sublevel and just go through all sublevels and set the reference of the sublevels = the refenrence of the persistent?

And i still don’t get why you even need this in your sublevels. The Skydome is everytime visible in the persistent level, so why don’t you just use the Persistent Level?

Thats the solution- in C++, just one line of code in the sub-levels to set the value, I guess in the constructor, before it gets reset to NULL. The sublevels inherit from the persistent level so the variable is just there, it can’t be removed. The sub-levels have to inherit from the persistent level because of the game’s AI.

No i mean, why do you even trying to work with the sublevels? The Skydome is inside your Persistent Level. If you want to manipualte it, why don’t you work the with persistent level then? Why moving the reference from the persistent into the sublevel to work with the sublevel? Is this because of the way your whole system works?

Ok, so to fix up this really long answer, i will post the answer here again in short.

You need to set the reference in every sublevel. It is only set inside your persistentlevel. You get your Sublevel and the reference there is still NULL. So working with the persistent level directly or filling the reference of your sublevels with some code would be the answer i guess.

In the C++ I am just working with the Persistent level. But, as you realized, the editor holds a value for the skydome in the sub level aswell, because it inherits from it. That reference is NULL, and cannot be changed in the editor. So when a sublevel loads, the persistent level’s reference to the skydome is set to NULL. That just happens, regardless of which levelscript actor I’m working with.

Ah ok, hm, that sounds wrong. The persistent level shouldn’t change this variable :confused:

Right. The variable needs to be passed around- the sublevels cannot be manually set. So in the constructor of the sublevel it needs to get the value of the skydome from the persistent level, and then reset the value of the skydome on begin play, in the persistent level.

Its a bug, an obscure one, but it needs to be changed- you should be able to manually set the variable in the inherited class, or the inherited class should inherit the manually set value from its parent…