Using Data Tables, Structs and Data Assets for an Inventory

I know this has been solved, but I’d still like to add a few things.

If this is for single player then having Inventory in the Pawn or Controller is fine. If multiplayer it is not. Consider network issues and the player gets dropped. The Pawn and Controller on the Server will be destroyed along with any data those actors and components are storing.

Player State on the other hand will persist on the server a bit longer… long enough to copy & store needed data. Thus anything that needs to persist in the event of a player disconnect (client crash, internet issue etc) should be stored in the player state.


I use Game Play Tags to identify interactive actors. For pick up items I use a 3 tier system.
World Item . Item Type . Specific Item … [WorldItem.Weapon.M416]

I also use Data Tables. For each Item Type I have a separate table for faster reading and to reduce load. [Weapons, grenades, ammo, healing, attachments, gear etc etc]

For any item that’s persistent in the game world such as gear and weapons (spawned and attached) I store DT data in the actual actor/component.

For example when I pick up a weapon the world actor (simple variant) is destroyed and the server spawns and attaches a high level variant to the pawn. On spawn the weapon configures itself based on the data table information.

I Parse the GamePlayTag to return a Weapon ID (name) for DT lookups. For weapons I have multiple data tables. Base Config, UI Data, FX (Visual/Audio), Ballistics (muzzle velocity, spread, recoil etc) and so forth.

Here are a few of the look ups. Note I’m soring the row in a struct in the actual weapon class.

1 Like