Best way to create and store a data type that might differ in number of variables with each entry

First of all, thanks to everyone who took their time to help me out!

Here’s what ended up doing:

  • As many of you suggested I created a struct and paired it with a Datatable to store the essential information about the weapons.

  • I made an additional struct that extends the first one and adds a few more variables that don’t need to be saved in the Datatable (Ex: Current ammo inside the magazine).

  • Instead of AActor, WeaponBase now extends UObject since UObject is the base class for all Unreal objects, and therefore, more lightweight. And also because actors are meant to be placed in the scene and that isn’t the case here.

  • I also found a slightly more “elegant” way around the fact that you can’t use constructors with parameters in Unreal by following the solution provided by akaPrometh in this forum post: Passing arguments to constructors in UE4? - #6 by akaPrometh

Brief explanation: You basically create a static method that instantiates the object, takes in the parameters you want and passes them to another non-static method that is going to assign the values to the variables (like a constructor would do).

Thanks again for all the help!

1 Like