How I can to do a start random map?

Hello guys.

I have 5 level maps and I want start random map when i click in start on menu bar.

Thanks for any helps.

I don’t know what you mean when you say “click in start on menu bar”; do you have a start button in a menu you’ve built? Is this supposed to happen when you launch the game? I have instructions below on how to create a method to open a random level. Where you place it and how you call it depends on what you want to do.

In whichever blueprint you decide to execute this method, create a new function called Open Random Level.

  1. Create an array of Names in the new method called Level Names.
  2. Populate the array with all the level names you want available.
  3. Create a reference to that array in your graph, and create a Random Integer node.
  4. Pull a pin from the Level Names array and create a Last Index node.
  5. Connect the the Last Index output to the Max input pin on Random Integer.
  6. Pull a pin from the Level Names array and create a Get node.
  7. Connect the output of Random Integer to the index number of the Get node.
  8. Create an Open Level node, connect the output of the Get node to the Level Name input.
  9. Connect the opening node of your method to the execute pin of the Open Level node.

If you have a start button and a menu, you can create this in the graph of your character or the menu graph. Tie the OpenRandomLevel method to the OnClicked event of your button (or however you are having the button trigger events).

If you want this to automatically run when you start the game, create a new, empty level. Set it as the default starting map, and connect the OpenRandomLevel method to the BeginPlay event in the level blueprint; OR, you don’t have to place the nodes in a new method, you can place them in the main graph and connect the Open Level node directly to BeginPlay.

Hi, I can’t to do this, it only start the first level, why?

I’m so sorry for delay to respond, and my english is not so good yet, lol

And thanks for help.

what your problem then?, you cannot start with some random map for obvious reasons, you need set your first level in your project settings, is inevitable, however you can set an empty map in the begining and do the previous suggetions, there is not diferences for human eye!

Yes, my first level is the MainMenu (Empy level), I took some pictures for you see where is wrong …


I just get to do!!! thanks so much huhuhu