Im currently working on making an inventory system and items and am not sure how to use it. i’ve went ahead and made item name and type enums as well as a data table and structure. My problem is how do i make the items functionable and how can i make a hotbar where when an item is selected to use it? thanks in advance.
Hi SpringBinkie,
Take a look at this free marketplace pack ’ InventorySystem ’ It looks like it provides some of the functionality you’re asking about.
Welcome to the Forums!
There are many, many ways to go around it; it really depends on too many factors to list here, they’re complex beasts!
how do i make the items functionable
Depending on the complexity of the item, it may need to be a fully fledged actor. The implementation of the use functionality should be encapsulated withing said actor. This actor could create and hold onto the reference of the widget that represents it in the UI.
how can i make a hotbar
It’s another widget that has a container to which the items’ widgets are added. The hotbar widget can be sitting directly in the viewport or be a part of a larger widget that makes the player’s UI. Again, depending on how you need it to work, you may or may not need slots in the hotbar, too. Those slots can also be separate widgets handling the most mundane functionality - highlights, sounds, clicks, context menus. They can be also responsible for handling adding & removing of the items (their widgets).
when an item is selected to use it?
Selecting (assuming clicking?) means interacting with the item’s widget. Since it was the item actor that created the widget, an Event Dispatcher is one of the most natural means of communication; but an Interface would also work well - especially when we start dealing with many unrelated classes.