Populating UI with 3 random choices (as buttons) from a list

Hi Guys

I’m working on a perk system where I want to present the player with 3 randomly selected perks from a list of all available perks and have them populate the UI after the player levels up, where they will then get to choose one. The end goal is to have these displayed to the player as buttons, and the player would click on the one they want. Certain perks will be removed from the list after being selected (activated), and other perks will be upgradeable and unlockable allowing them to be selected up to 3 or 4 times before being removed off of the list, or having certain criteria to be met before being added to the list. i’m unsure where to start with this, here are the thoughts I have so far, but any input will be appreciated.

Creating each perk as an Enum element and choosing 3 random Enum elements (somehow?) from the list and passing the info to the 3, waiting, buttons (using Structs where necessary), then activating these perks within the character blueprint from inside the perk selection/level up UI. Using a Struct here will let me pass on additional info on whether the perk is upgradeable or not

or

Creating each perk as its own button, creating all the perk buttons and setting them to invisible and choosing 3 random buttons to appear in the UI visibly (this seems inefficient)

I’ve seen documentation on implementing an ability system through C++ but I think it will be overkill for a simple random perk system

Also, do you think the perks should be on the main character, or on a separate blueprint?

Thanks in advance

I similar solution I implemented for a different use case, was to create a button template, add a struct to it with all the info of the perks, and a name or number variable exposed on spawn.

After that create a data table with your struct and all the different perks and what they will modify, maybe make it an array so you can have different levels for each perk.

When you are adding the 3 buttons to the UI, do a random integer for each, and based on that integer get a data table row, and feed that into the button you are spawning. So the info of the new button will be the info from the data table.

Only thing you have to add somewhere, probably on your character, is a variable that will store the level of each perk your character has. That can also be exposed as an input to your buttons so you can display and level up to the proper stats.

After you have everything working, last thing you have to do is make a save game, so you can save these perks levels, but that’s pretty easy.

Hope that helps.

Thanks for the response, I managed to get a system up and running over this week, your explanation is exactly in line with what I did.

I used a struct to set up all the data and created a struct array on the player character with the array pre populated with all the perks, one of the struct elements is an enum with the name of all perks which controls a switch on enum function on the player that handles which perk has been clicked on from the perk menu.

I’m still having some trouble removing the perks from the array so they don’t show up as repeats when populating the 3 buttons, as well as the levels for each perk in order to remove them permanently from the array once at perk-max-level, but i’m feeling more confident with the system now, esp after your response matches up so well, thanks again for the feedback and for the ideas

Glad to hear you are getting the hang of it. It’s so satisfying when things start to click.

You can make a temporary array when adding items to the screen, and checking that one to make sure you don’t add duplicate items.

Same with max level, you can add a Branch to check the level of the perk, if it’s lower than “max level”, then you can add it. If not, add the next one in line.