Open Level - Trouble Opening Next Level In Index

Hi,

I’ve been following the tutorials here and have reached a roadblock trying to get my next level to open based on a button click.

This is my Blueprint setup:

I’ve added an integer to take into account the next level index. However when I finish “Level_000” and want to go to “Level_001” the level starts from the beginning when I click “Next Level”. Does anyone know a way to fix this issue?

Thanks!

Edit:

I went back to play with my game and found out that when I play from the “MainMenu” level it starts as “Level_000” but is in fact a different map, and when I click next level it proceeds to go to “Level_000” which is the level I do want to be the first level. The next level button does seem to work to some extent but just not on the levels, or in the order I would like it to.

Edit #2:

I tried to create a level select menu through an on click button. One button would open Level_001 and another would be directed to open Level_002. When I tried this out in game both buttons when clicked would open Level_000.

Tell me about your level list please and where you get the opportunity to click the button you’re showing.

Also tell me where do you set the “LevelIndex” variable of your Player Character.

Also, you’re removing your Widget from its parent before calling an open level, just get rid of the “Remove from Parent” - this destroys the widget and might prevent it from executing any other actions.

Also, why are you “Adding to Viewport” here, this means you’re trying to display the widget in which the button is. But if you’re user is clicking the button, it means it’s already being displayed. You can get rid of it too I suppose.

Thanks for getting back to me :slight_smile:

My Levels are placed under my Maps folder:

When I go to Window -> Levels, I get a different set of maps.

When the player reaches the end of the level by colliding with the black box, the EndLevelMenu appears which displays the Next Level button.

Levels3_Error2Unreal.png

I set the player index on the EndTile Blueprint, which is the black box the player is colliding with in the picture above.

1.)
Is the “LevelIndex” variable persistant through the levels? Means: is it a Variable of GameInstance or is it saved/load with savegame?
Cause as far as i remember, variables of Blueprints get reset during level loading, when not set inside of a persistant Class like GameInstance.
So, your Level index will always be 0 at start of a new level… Doesn´t matter of you put a add Node behind :slight_smile:

2.)
If i look at your first shot (OP), you add 1 to LevelIndex - But forgot to SET the new value into LevelIndex.
Means:
LevelIndex = LevelIndex + 1
See:
vywqqq5g.jpg
That way your LevelIndex is read, increased by 1, and than Set to be the new value.

Thanks for the help :slight_smile:

It’s not a variable of GameInstance, I placed the variable within my EndTile blueprint. Within my EndTile blueprint I created a Level Setup which contains the Level Index. I can change the level index here before starting a game and it will load the appropriate level. It’s the transition between levels that does not seem to be working.

I created a GameInstance and set the level index within there but that didn’t seem to resolve the issue.

I also tried to set the level index like you have done but it does not allow me to create a Set Level Index when I try to make a connection from int + int.

I keep trying to find the issue with the blueprint but am at a standstill.

If I set the Level Index to 3 and I begin the game, this is what happens:

  1. Game loads Level_000
  2. The StartLevelMenu displays Level_003
  3. The BestTime for Level_003
  4. Text for begin Level 3

When I run through the level and click on the Next Level button this happens:

  1. Game loads Level_004
  2. The StartLevelMenu displays Level_003
  3. The BestTime for Level_003
  4. Text for begin Level 3

When I run through the level and click on next Level it repeats what happened above.

Would anyone have a clue what might be happening and where I could look to make a fix?

I suspect your “Cast to character” in your “EndTileBP” to fail because it is not loaded yet whereas your end of the level is. You should add a print to it and see what it says.

And if you have a “EndTileBP” in each of your streamed level and if they are all loaded at start, they are all going to fire.

I suspect your “Cast to character” in your “EndTileBP” to fail because it is not loaded yet whereas your end of the level is. You should add a print to it and see what it says.

[/QUOTE]

Definitely see what integer it is outputting with a print string! Also not exactly sure why you’re creating a new widget and then removing it from parent on click…I don’t think that code is needed is it?