Just to be clear. I already have more or less fully working, networked inventory system and items. What I’d like to ask here, are some idea of how to do it differently/better.
First of what UI must do:
- Display item name.
- Display item statistics.
- Display item icon (or other visual representation).
- Display list of effects attached to item. (not required, could be part of item description).
Currently I handle my inventory by storing path to blueprint assets in DataTable. One Blueprint = one item. Each item is derived from AARItem, which is derived from AActor.
When item is added to inventory, client just spawn AARItem and pull information about item from spawned actor.
You can instantly see it’s not perfect solution, when client has to spawn for example 100 actors in row, to fill your average RPG inventory. This of course can be partially mitigated. Once actors are spawn, they can be serialized to disk, and just loaded from here.
Server only holds information about ItemID, and do not spawn any actors, unless item is equipped from inventory to character.
My other idea, was to store information about item in DataAsset. Information like statistics, description, effects, meshes, etc. And just read data from here. Of course storing in DataAsset have a downside of the fact that TArray, can be searched only linearly. with 10-20 items it’s not a problem, but with hundreds and possible doznes of searches per second it can quickly become problem.
So last idea, is to do exactly the same thing I wanted to do with DataAsset, but create custom asset type, which will store item information, in TMap.
Opinions ? I honestly like option with actors, even though it’s probably not the best it is quite simple, easy to handle, and easy to maintain. (it’s enough to make change in parent class to propagate it down the inheritance tree).