Interacting with objects within the inventory

Hi everyone!

I made a simple inventory system using blueprints. Pickable objects have an structure, so when you pick them up they’re stored into a map and then destroy themselves.

Everything works fine, but now I want some objects to be interactable within the inventory. If it was just a consumable changing some stats I’d use structs, but I wanted to add some dialogues in which you inspect the object or manipulate it.

It would be easy if I could write the code of the interaction inside the interactable object: I could add a “UsingItem” function inside the parent class, override it on its child and make it do whatever I want, so in the inventory logic I could just check which item is selected, get a reference of it and call his “UsingItem” event.

The issue is that I can’t call any function since the object is destroyed when you pick it up.

If anyone has an idea about how can I cope this I’d love to read it!

Take care everyone!

you can use UObjects instead of structs for inventory items, then you can run functions on it.

otherwise you can make an effect class in the struct and spawn it on Use

or have some sort of global item manager that applies the effect

1 Like

Changing the structs to Uobjects is a great idea, I may do that with the usable items.

Thank you a lot!