Open Level Options

Hello. I want to travel between levels without level streaming. I tried Open Level node but I couldn’t figure out Options. I saw some posts say I need to put GameMode URL there but it doesn’t work. Can you help me?

Thank you.

2 Likes

Thank you for your answer but I am doing this. I want to know how to pass some variables with the character. When I do this, everything gets resetted like you just started to play the game. I want to know what should I do with the Options node to pass all variables on.

You can created a box collision actor to trigger a level change. Do “OnComponentBeginOverlap(Box)” to an “Open Level” node. The level name inside the node is going to be the name of the level you want to open. When you walk into the box it will automatically open the level up.

96111-lev1.jpg

is there a way to store existing TopDownCharacter’s variables on GameInstance now? Game is kind of close to be finished.

to pass variables between levels, store them inside a GameInstance, or save them in a SaveGame, and load them on the other side.

1 Like

As long as you create a variable inside the GameInstance and set it from your character’s blueprint, you just have to cast back to it to retrieve the value of it when needed. If you do not have a GameInstance then just create a new one (I called mine GameInstanceX) and go to the Edit>Project Settings>Maps & Modes>GameInstanceClass and change the default to the one you created. These will stay stored here until you shut down the game. If you want them kept longer then you will need to save them the the SaveGame feature.

Do I need to set all variables or is there an easy way?

Sorry for the late reply, you have to set these variables in the game instance from where you control them from. From your event begin play, you need to cast the the game instance from whichever blueprint you need to communicate with it and then create a reference for it. Use the reference to get the variable and set the variable. On the second image I am setting the variable from the blueprint communicating with the game instance (shown on the left). This stores the variable in the game instance. When you need the variable data later you just drag out the game instance reference and “get” the variable you want, and then use it to set a variable in the blueprint communicating with the game instance.

2 Likes

Okay thank you, I will do that but what should I write to ‘Options’ tab in ‘Open Level’ node?

From all the research I did on the Options pin, it is pretty much useless.

So, how I am suppose to transfer variables when level is changed then? lol

First make your variable in the game instance that you want to transfer. Basically inside the Level1 blueprint for example you are setting the variables inside the game instance with the same info as what is inside the level1 variables. Once level2 is loaded it will take the game instance variable and set the variable inside level 2 blueprint. I naved the variables so you can see where they are stored at.

You could use options string that can be passesd while loading levels.

Passing “Value” under variable named “Variable”:

Reading data in new level (must be performed in blueprint, that derives from GameMode class):

This method is pretty limited as passing around complex structures involves serializing and deserializing it from string. Also, passing object references isn’t possible I think. For such cases, storing data temporary seems like better choice, tho I find it pretty ugly. :confused:

6 Likes

You would have to set each variable separately.

I am doing it with GameInstance and SaveGame but I can’t do it right. It doesn’t work. I am saving the game with trigger and it prints correct, then I load it, prints correct again but the character spawns with default values not with saved ones.

Still doesn’t work, its driving me crazy.

Are these nodes correct? Can you help me if you know about this?

Spawning will always load default values. That’s normal. You need to fill in the Variables values after spawning. Or you expose them (There is a boolean in the Variables options window) and directly fill them in the Spawn Actor node.
But technically, that’s the same. So filling in the data needs to be handled AFTER you spawn the Character.

Can anyone help?

If you are storing your info in the GameInstance then you need to load them to the GameInstance and then set the TopDownCharacter variable with it. This is the way I would do it In a FPS Example.