Hello, I’m trying to design an inventory system where my items are not actors, but they just inherit from UObject. I designed all the logic, and if as container for my items I use
UPROPERTY(EditAnywhere, Instanced)
TArray<UBaseItem*> Items;
I can simply add items in the editor and everything is working fine.
However what I want to use is:
UPROPERTY(EditAnywhere, Instanced)
TMap<UBaseItem*, uint8> Items;
But this is not allowed since Unreal is telling me that TMap can be Instanced only if the value is an object type, so I tried to insert items in the map directly from code, and here the problem arises.
How to do that?
I tried something as simple as
UHealthPotion* Pot = NewObject<UHealthPotion>();
Items.Add(Pot, 1);
But then the item does not appear in my UI (even though it was appearing with the “Instanced” TArray.
This looks like a really stupid question, but what am I missing here?
Thank you in advance.