Download

Inventory Discussion: Object Items vs. Actor Items

I’ve been messing around with Inventory systems recently, watching tutorials and trying to analyze other inventory systems from Marketplace to try and get a better grasp of the how’s and the why’s (which is a slow process because I am, in general, not that bright).

Regardless of the overall style of the inventory (Slot-based, Lists, etc), they seem mostly the same in a lot of ways, and they boil down to arrays and structs, but one large difference I’ve noticed is some people use Objects to store an item’s data, some use Actors.

My question is, what are some of the key differences between these two methods?
Pros and Cons? What sort of situations might one be more suitable than the other?
What if an item needs to be modified, such as enchanting a sword for increased damage or adding an element, or an extended magazine on a firearm?
Is one more suited to Singleplayer vs. Multiplayer?

Why not pawn items? that’d be useful, Well in my case I use actor and you can drop them throw them eat them hit with all of them and that is useful, inherit as much functionality as you can.

I realize that this thread is a few month old by now but man that’s one bad advice, if I ever heard one…
So let me put my 2 cents in there:

As always in programming there’s usually not the one solution for everything and a few things to consider.
If you want to use and object or an actor depends a lot on the game (or inventory) you want to make.
E.g for most single player shooter, Actors should be fine. (Similar to the shootergame example). If you have an RPG with a big inventory, you may want to consider objects, though since they are not that performance heavy. There are probably a few optimizations to be done for unused actors but I guess a simple UObject or struct will always be better. Add network replication and it will only get worse for actors and at that point you may want to consider splitting your items up a little bit.
Personally I like to have my static data in DataAssets that are simply referenced by the Item, otherwise you’ll end up with hundreds of M4s all with the same firerate, max ammo, spread values etc copied everywhere (and with that lots of wasted memory)
Now if you have a e.g. crafting system that allows to craft items with some kind of quality these stats may be different from item to item, so there could still be the need to actually do that for some values. You could always calculate the actual values from the base dataAsset and some quality value but I’d say, just save them in your item and be done with it.
And last but not least, you probably want to have different actors for pickup items anyway. They will most likely not need a skeletal mesh like some weapon or usable device might need and instead can just use a static representation.

In Conclusion, I’d say the bigger and more elaborate the gamedesign the more it makes sense to split all that stuff up. Have DataAssets for static data, item-objects for the inventory items, and actor for pickups-items and anything that the player can equip. But don’t overdo it from the start (always keep Yagni in mind^^)