I’m now asking the GameInstance BP to give me the randomly selected level name to open the next level.
But this doesn’t work and I think it’s because the RandomName variable from GameInstance BP is only given the text once. Is this the case? What can I do so that whenever a widget BP is loaded (or whenever that widget BP’s level is loaded) GameInstance BP will do that again emptying the last RandomName variable?
That is what I did previously but I now want to pick a random level then never pick it again. If I were to let the array in the widget BP I wouldn’t be able to remove an index from the array.
it sounds like you want to make a playlist of level names. in that case, i would shuffle the array, by creating a new empty array, and choosing a random element from the level names array to copy to add to the new array, and remove from the old array. repeat until the old array is empty, and you will have a shuffled array. then, each time you load a new level, you should increment the integer you use to get the next level name, and if its greater than the length of the array, set it to 0 to start over with the first level on the list, or just end the game.
Just one thing, you should put this in your gamemode instead of your gameinstance probably. The gamemode is a little more authoritative to the state of the game than the gameinstance.
In general I like to think of the gameinstance as the application itself running on the local machine, and the gamemode is the thing in control of the game.
You can certainly put the logic wherever you want, but if you ever try to do networked multiplayer, you’re going to have to move it there anyway, so may as well have it there to start with.