Load next level from an array or list?

I know how to use onactor overlap to open a level. However, I would like to make a blueprint attached to a static mesh so that when the player enters the goal of a level it will just open the next level in a list off all the levels. I.E. player reaches goal of Level 1 and it loads Level 2.

You can use a select node for that , like this

I would like to propose another solution. This is maybe because I am using Unreal 4.19, which is a lot newer. When I tried to use this screenshot to make the levels seemingly flow from one to the other, it would work for the first level, but not the second. This is because the index never changes, which is option 0, so it will always open the option under index 0. What I did was I used this blueprint as a starting point, and worked from there (slight difference, I used a button to travel to the next level, but essentially the same). I created a String array with all the level names in it. After this, I used a “Get Current Level” node, which finds the name of the current level. The name is then sent to the “Find” node, where it finds the index of the level name in the “Levels” array. I then send this value to an “Int + Int” node, where the index of the current level is added to the value of 1. THIS index is then sent to the select node, which gets the next value (So if original index is 0, +1, the new index is 1, which gives us “Option 1” in the “Select” node). it then opens level 1, and the whole process starts again. you can add an infinite amount of levels to this select node, but make sure you add all the new levels to the Level array too. Hope this helps for anyone finding issues with the blueprint above! (You can of course copy the nodes in the screenshot also. I thought I would share this solution, as the original didn’t work for me, and finding this solution took me 5 days…)

If you are using a trigger like the original question asked, remember to cast to the Player Pawn/Player Character after the Event node.

So, this is quite round-about there are much simpler solutions. Also the “index” doesn’t change because it is a variable that you assume gets changed wen you complete a level. So yes, just recreating the screen shot above would not work the index would always be 0. But in the context of a much larger implementation this would def work because you should be incrementing the “index” variable each time the player finishes a level. My method was to name each of my levels a very standard “Level#” so using that method all I needed to do was add the number at the end to get a reference to my level names. I have an actor in each level that keeps track of what “level” it is on. So this is where the variable “current level” is changed based on the specific level. And when the player saves (in my case) the level it will pull this information and know where to start when the player loads the game back.

This is a much simpler way of doing it, I agree. I however am not a specialist by any means when it comes to blueprints, i create the visuals. And this would be why I missed a key detail, which is saving the variables to a Save Game. As my game restarts every time the player goes back to the menu, I will stick with my solution, but your way is a much simpler way to do it, and I wish I had found this for myself.
Thanks for the response.

No problem just didn’t want someone coming by and being confused by the same thing you were so I thought I’d clarify. And I am terrible at “the visuals” haha We all have our strengths and weaknesses. If you need help with blueprint logic don’t hesitate to ask. If it is something I know how to do I’ll help you make something efficient :slight_smile:

Hi, from where came your variable Current Level (Game)?

It is a variable I created in my actor that I place in each level that keeps track of global level details such as what level is being played. I made the variable instance editable so each new level i placed it in i could set the level number manually through that actor.

Ok, i have a problem with that im use only my logic to next level over my parent BP_Enemy and make a check enemies on the level using a get all actor class and after that store on a variable and when the player kill one enemy decrease this variable. When this variable reach 0 open a portal to go to the next level. This work ok but my poblem is always go to the same level jejeje

Here this is over my BP_Enemy Parent:

Try this method from video #14
Unreal Engine 4 Beginner Tutorials: https://www.youtube.com/playlist?list=PLyu-W38DvZhqByAoeva1jewB5s78zQHIy
I did it with coins but same principle