So I’m trying to make a character selection screen in my game, and I have many different levels in my game and I don’t want a character select screen to pop up every time the player goes into a new level. This is what I have so far. The first image is of my character select widget, each of the character buttons are represented as an int. The second image is of the level blueprint. In the Level blueprint, it’s using the int given from whatever button was pressed in the character selection screen and spawning in the character selected. That’s how it should work, however, no matter what character is selected it automatically chooses the first one.
The game always spawns the default character even when I selected a different one. How to I fix this?
Are there any pawns in the level with auto posses turned on? Or a game mode set in world settings with a default pawn class?
Also make sure the character selection is made before that level loads up because the character is spawned on EventBeginPlay so the selection has to be made before the level has been loaded.
The issue is most likely in your Event BeginPlay. You are spawning in the character based on your int as soon as the widget is spawned in. Change the BeginPlay event to a custom event that you call when one of your character selection buttons is pressed to change the int before you spawn in a character.
EDIT: To test if this is the issue try changing the default value of CharChosen and see if a different character is spawned in.
The Character Select screen is in the main menu, so it’s before the level is even loaded. And the game mode is set to none for the character
The Character Selection screen is in the main menu so it’s before the level is even loaded. So the screen isn’t being loaded when the level loads. For some reason when the level loads it always goes to the first thing that’s on switch on int.
Try adding print statements 1) where you set the int and 2) where the switch is called. In both places have it print the int value. This should tell you whether the issue is with the set or get functions. Lmk what you find out!
So I tested what you said and on my character select screen, it seems that the only button that seems to work is the first one which is why it’s spawning only spawning in the default ball. I’m going to to try resetting the buttons on clicked event and see if that fixes the issue.
So it seems that I just needed to reset the on clicked event for each of the buttons, Thank you so much for your help its much appreciated. I’m going to mark this answered unless something else happens to come up with the character selection screen again.
Great to hear this is fixed! Glad to help
That helped me 5 years later thanks. Same issue but mine was about default pawn classes in different levels. Thanks.