Loading the Next Level (UE 4.27)

Regarding what you have in blueprint right now and not your main post: usually you want to avoid many copy / paste and try and make things more automated.

For example, you can use a Struct to know what level has been completed or not:

// pseudo
struct LevelsStruct
{
    int32 LevelOrder; // Same as array?
    FName LevelToLoad;
    bool bLevelCompleted;
}

Have an instance of the struct per level in an array. Like this you can loop from lowest to highest looking for the first level that has not been completed. This one will naturally be the next level to load:

// pseudo
ForEach LevelsArray
{
    if !LevelsArray[i].bLevelCompleted
    {
        // Load level.
        // Break loop
    }
}

Looping like this will always load the next level that has the bool set to false. So if index 0 is false, meaning not completed, it checks to load next level. When level has been completed, set that bool to true and run the even again to get next bool that is false:

// Start For Loop
// loop 0
LevelsArray[0].bLevelCompleted == true // Skip
// loop 1
LevelsArray[1].bLevelCompleted == true // Skip
// loop 2
LevelsArray[2].bLevelCompleted == false // Load
// Break For Loop

Hope it makes sense… Wrote it like this because do not have access to UE right now. I’ll do it with BP later. The idea is to make it less iterative and easier to just add / remove / reorganize levels.

Having a struct will the info of each level will also make it a lot easier to load specific levels.