Collectible Item Lists Unlocks

Hello !

I want to create a game mechanic where the player can collect discs by exploring the world the game.
In the menu, the player will have a collected discs section.
In this section, there is a long scrollable list of 100 Discs with Numbers “Disc0,Disc1,Disc2,Disc3”

The Player will see all the Discs, but the ones he havent collected will be greyed out but the ones he did collected will be displayed in colors.

The Player cannot click on the greyed out discs obviously, but he can click on the ones he unlocked.
Doing so will open a text document, similar to a journal note or Something similar.

For now, i have a BP_Disc that have an integrer instance editable, i Place the disc in the level and i can assign it with an index in the detail panel.

When i collect theses discs, that index data is sent to the Widget.

But the issue is that i need to create 100 buttons in my widget, and by doing so, i need to “unlock” them individually when picking up a new disc.

this is a massive issue, because it forces me to have 100 on clicked event, 100 buttons, and 100 lines of blueprint code to unlock each individual buttons.

Is there a way that i could automatically create all theses disc buttons from 0 to 100 and space them properly on different lines and collumns, then upon picking up a disc, get its id, find in the generated buttons the corresponding index and finally unlocking the correct disc button while having One single OnClicked event that would transmit its execution to the proper data ?

I know this sounds complicated, but i feel like it should be possible, i’ve seen this in many games, mostly with notes or journal pages or with a collectible images list but also with bestiary systems, where the list items all exists but are greyed out and become avalible when discovering the correct element.
Another example with the Unlocks menu in Binding of Isaac.

If you guys know of a tutorial that could help, or some kind of guide or even code example, i would be extremely gratefull.

Thanks !

I would suggest the following approach:

  • Create a Data Table with all disc info. The row name (Disc0, Disc1, etc.) serves as the disc ID.
  • In your SaveGame, keep a Set container of IDs representing collected discs.
  • The widget populates dynamically from the Data Table, and for each row, it checks the SaveGame Set to decide whether to show it in color (unlocked) or grey (locked).

Let me k ow if you need more info.

Interesting approach, but how would I be able to differentiate the on clicked events for each object in the list ?

Would it be some sort of children widget with a bit of code that would be instancied for each element ?

Yes. Every child widget is instantiated with its own DiscID, and when it’s clicked, it reports that ID. The parent receives the ID and knows exactly which disc was selected.

In short the widget container instantiates the widget and assignes the id in same order as the data table. Every event can span from there.

Okay, I think I get the idea, but a last issue would be to generate all of theses children widgets at the correct location in the list.

Imagine I want to stack them in a grid one by one and each instance added would take the next slot left to right and when the row is full go back down left and repeat the process.

I guess I could do it mathematically with some repeating offsets but that seems a bit too complicated.

Do you think there is a way to have some sort of grid container and fill it slot by slot by incrementing an index of some kind ?

I would suggest using the Wrap Box

Here is a simple demo project of what I suggest. There is room for improvement, it’s just as a kind of proof of concept.

Summary

Data folder contains the data table with the info for all widgets. In Content | Data there is the .cvs used.

Blueprints folder has the widget class of the button (BP_W_CollectibleRow) and the BP_W_List that uses the data table to instantiate the buttons. The level blueprint adds the widget to the viewport.

SaveGame folder has the save game object, game instane class and blueprint interface used. Idealy this would work better as a game instance subsystem.

During Play type the ID that you want to add or remove and click Submit. It should add/remove it to the set and save, then reset the buttons.

Collectibles_UE5_6.zip (247.3 KB)

@cl_fabula does it work for you?