How to know how many maps you have joined?

Hello! I’ve made a function that after five minutes the player will go to a random map/level. There are five different maps and it chooses one of them randomly. (you click start and then join a random level between 0-4, then a timer starts and after the timer ends it then again chooses a random level that you then join from 0-4)

I have two problems. The first is that I want to know how many maps I have been to, for example, I want to be able to do something (show a widget/stop the game/something like that) after the timer ends on the final level(the fifth level). I could do this manually and have a different timer actor for every level and have a different game mode/ game instance function but I think that it would be easier to have a more automatic way.

The second problem that I think is much harder is that I want to know which level I have travelled to so it doesn’t choose that level again.

Thanks for any help!!

Both of these can be accomplished using the game instance. It lives between map loads.

You can count the maps just using an integer in the game instance.

Just make an array of map names in the GI, shuffle it and then always pick the next one off. The way you don’t visit any map more than once…

Thank you for the help!! Ill try this now.

Once you’ve created your GI, be sure to put it in the project settings under ‘maps and modes’

Would I just have to plus that interger everytime a map loads? Then when is reaches a certain number e.g 5 tell it to show The end game widget/do the end game blueprints.

Just do it all in the GI:

Then in each level BP:

If it’s not too much how would I put it into my code? The first picture is my game mode the second is my game instance, and the third is my timer. Thank you for showing me blueprints!!!

I think that I will actually change my random level function for your one. It seems better. Thank you so much, I changed to your system, and everything works. Thank you so much!!!

I tried to make it fairly generic. You can just call the NextLevel node when you want to switch levels.

Naturally, I recommend my shuffled array method of picking the next random level :wink:

If they have a set amount of time before the level switches, just call NextLevel when the timer runs out.

Tell me if you can’t get it working the way you want…

Hey so because it’s online I stumbled on a little problem that didn’t happen when I had the joining world but because it’s online I have to use the execute console command and append. For some reason, the code just isn’t working. I don’t understand because it worked perfectly when I had the join world blueprint but now that I’ve added the append and execute console command it’s not working. I hope you can help :))) (Thank you for all the previous help)

Afraid I don’t know about that part, you might need to re-post with that specific question…

will do but thanks!!!