Level streaming "should be visible" calls beginplay

Hey there,
I’m using level streaming in my game. When pausing the game, it hides an already loaded level (set bShouldBeVisible to false) and loads a level instance for the menu. When the player exits the menu, it is unloaded and the precedent (stil loaded) level is shown again (bShouldBeVisible=true).
I’ve noticed that each time the level is set to visible again, all beginplay events are called. Should this happen ? Since I have random variables set at beginplay it’s pretty annoying, these values change each time the menu is open/closed… I want to set them once at LOADING until the level is UNLOADED (not only hidden).
Any idea ?

EDIT : after further tests it looks like the actors are kind of reset, events that have been fired before are considered as not fired. But actors that have moved are in the same position. Could someone explain me this please ?

Should I save my whole level as a savegame and load it again to get the same status of all my actors after the menu is closed ? If yes, how can I achieve this ?

I actually don’t know if it’s normal behavior, but maybe you can just set a bool in the Game Instance and just use it not to execute the Begin Play functions the second time?

I’ve checked to be sure : the level is still loaded (not unloaded at any moment). But making it visible again calls BeginPlay on its actors and in the level blueprint.

Well I was thinking about something less fastidious thant adding a bool to ALL my dynamic actors… But I think it’s a way…

Aaaand no. It doesn’t work. Let’s talk about one specific actor in my scene : a screen with a widget shows some informations about the game and the player’s progression. The screen is initialized after a certain action (usb key in). When hiding/showing the level, the usbkey is still in, but the screen is not initialized. As if the actor has been reset. So the problem here is not only the BeginPlay event…
EDIT : to understand me, I had set up manually the initializing at beginplay for debugging purposes, and that has shown me the issue.

Sorry, I’ve just started figuring out level streaming, and my first thought if I wanted to create a main menu as a separate interactive (or just animated) level, I’d set the level to the side of everything else, and when the player presses pause - just load the streaming level and switch to the camera set in that main menu level, maybe with a little fade to black in between.

I just can’t really understand why you need to set the level you’re in to be invisible. Do you somehow load the menu level on top of another level?

P.S. I just tested the Should Be Visible node. Begin Play is indeed called every time the level is set to visible.

Another thing: I’ve just tried to create a setup with additional main menu level I described and there’s one issue: when I set view target to the camera in the menu level, the level that should be loaded gets unloaded, and when I set view target back to the character, it loads again. However, if I don’t use a streaming volume, but set level loading and unloading in the persistent level BP using trigger boxes, the levels stays loaded. Streaming volumes must be reacting to camera; and trigger boxes get overlapped by the character, that’s why the streaming level remains loaded at all times.

So my another question is: do you switch to another camera for your menu level?

My bad, I probably should have been more precise.
Here we are :
It’s a VR game with one only pawn (and one only camera). My setup is a persistent level in which I load different levels (main menu, the “game” himself (one only level), end level with cinematics, etc). In the game level, I have an option to open a Pausemenu level. This action makes pause (set the global time dilation to 0.001), hides the game level and spawns a level instance of the pause menu where the player is in the world. I used this to avoid to move the player here and there.
However your suggestion (use another camera) puts me on antoher direction : I’ll try to pout my pausemenu as another level and on pause menu open, I teleport the player into it - and go back on place when pause ends. So that the game level can keep going without being hidden. I’ll let you know.

BUT problem still exists about beginplay and showing a loaded streaming level.

If you teleport the character back and forth, it will begin an end overlapping the streaming volume (or the trigger), and your level will be loaded and unloaded, so your begin play problem will remain. Plus you’ll have another problem of having to save player rotation and restoring it after unpausing.

Maybe you can place another pawn in the menu level and just possess/unpossess it, so that the main character stays within the streaming volume and the level doesn’t get unloaded?

I don’t use streaming level volumes, all loading/unloading events are called using blueprints. And by experience, possessing/unpossessing VR pawns are quite a mess (due to the camera/HMD location different from the pawn’s location).

Ok keeping the level loaded on another place and teleporting the player inside is working. Quite a workaround though.