How do I add functionality to my items that are derived from a Data table in one actor

I’ve wrote a similar question like this recently but I feel like I didn’t elaborate enough on my question, I have an inventory system and pickup system that works with UDataTables and all my items are being handled in 1 class called “PickupBase” which is just 1 actor class handling all the items in my game.

now the issue that I’ve run into is that I have no idea how I’d go about adding functionality to each item since every item is in the same class. How would I go about referencing each item so I can give every item its own functionality? Like for example if an item is classified as a gun, when i pick it up it plays an animation that I’m holding the gun.

Someone in my previous question said I had to use “FindRow” on my datatable but I was confused on where I would put that in my code, would I put it in my “PickupBase” class or would I put that in my inventoryComponent class? I followed a tutorial on how to get this inventory system working and I’m just pretty lost on where to go from here.

It’s a hard question to answer without knowing more about how the items/inventory system works
But I would guess your Data Table contains the definitions for your items, so perhaps in your definitions you can have a property that differentiates between the different item types. It could be an enum, or perhaps a gameplay tag.

If your items spawn an actor when picked up, perhaps your actor can have a function, maybe OnPickedUp, which you could do different things in depending on the type of the item. Perhaps you can have different classes inheriting from your Item actor that implement the function accordingly.

1 Like

I appreciate the advice, I’ll probably try to figure something out similar to that

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.