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.
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
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:
That way your LevelIndex is read, increased by 1, and than Set to be the new value.
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 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?