Best practices for creating a weapon system, possibly using DataTables?

Hello, I have a question about best practices for creating weapons in a game and whether or not to use Data Tables.

For context, I am creating a weapon system where there are Guns and Swords, and I am using the Gameplay Ability System.

Obviously, guns and swords are both weapons and share properties such as Damage, however Guns do not have Hitboxes and Swords do not have Ammo.
My original plan when I first started this project was to have a C++ WeaponBase class that stores an array of GameplayAbilities to be activated based on their GameplayTags such as PrimaryFire and SecondaryFire that would be granted and removed when equipped/unequipped. Then, I would have GunBase and SwordBase C++ classes that inherit from WeaponBase. The GunBase class would include additional features such as Ammo and the SwordBase would feature a Collider/Hitbox component. From there, my plan was to create child BPs of these two classes to create many Guns and Swords.

My questions are as follows:

  • Would Data Tables be useful to make the game design process better? My concern is that Swords’ hitboxes need to be individually adjusted for each weapon, which I feel necessitates them each having child BPs.

  • Does this negate the main benefit of DataTables, or would it still be useful to take a hybrid approach and have integer stats like Damage be in a Data Table while still creating lots of child BPs?

  • One idea I had to reduce the number of GameplayAbilities was to store Guns’ reload animations in DataTables and for the majority of generic guns use a generic “GA_Reload” that simply accesses the animation from a DT. Is this recommended?

In my experience, you are still gonna end up with a lot of child BPs using data tables or not but that does not mean data tables are useless, the main advantage data tables you will still have whether you have tons of BPs or not, that is editing all the stats will be done in one place and you won’t need to open up blueprints to set damage values etc. Not to mention it makes designers happy.

This really helps in large projects but for smaller projects it okay to forgo data-tables.

as for inheritance it also depends on you, if you have a crystal clear design in your mind about how many weapons will your game have and how each weapon would fit into the category then its okay to go with deriving classes, if not I would suggest try components first, you can easily make a component that manages hitboxes for swords, and have everything controlled via interfaces.

as for your last idea about storing reload animations in a data table and having an ability reference it, I personally haven’t tried it but I see no reason it would not work, as it is almost same as getting the reload animation from character’s weapon.

1 Like

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