ItemBP
| … Weapon_SK_BP (high poly functional … high data)
… | … WepSK_M416
… | … WepSK_AK47
… | … WepSK_Colt1911
.
| … Weapon_SM_BP (low poly world drop variant … low data, no functionality)
… | … WepSM_M416
… | … WepSM_AK47
… | … WepSM_Colt1911
.
| … Wep Attachments
| … Wep Ammo
| … Consumable
This is the structure I follow. Base item functionality is in the parent items BP.
e.g.
“Weapon_SK_BP” has all the firing, fire mode toggling, scope zeroing, reloading etc logic for the weapon…structs, configs etc. The children inherit and utilize a config to enable/disable functionality and set weapon specs. Firing modes, recoil, sway, gravity, velocity, per bone dmg and dropoffs, max mag count, reload speeds, sounds, fx, anims/montages, 1 or 2 handed etc etc.
The Player Controller/Character references “item events” for all actions.
e.g. Player presses fire input -> input action checks if there’s an equipped item, then if the current equipped item has a fire event (Switch), if so it’s executed, otherwise nothing happens/is executed.
WepSK has a config var to reference its WepSM variant and vice versa. Game mode spawns the SM version that the player can interact with (pickup). On pickup it’s destroyed and the SK variant is spawned into the game world attached to either characters back/holster or hand. On Drop the SK is destroyed and the SM is spawned on the ground at the players feet. The SM has a struct that contains the attachment data copied over from the SK.
WepSK and WepSM have their own inventory system for attachments. Anything attached (grip, scope, muzzle, stock etc) is stored in said inventory. If the attachment is removed it can go into the players primary inventory as a loose non-stackable or it can be dropped into the world. Thus when the weapon is dropped all attachments go with it, unless manually removed prior to dropping.
My approach to the primary inventory system and slots is straight forward. Actor Component with structs.
Primary slot, Secondary slot, personal defense slot, Melee slot, throwable slot and loose bag.
Each “Slot” is configured to only hold a specific type of item (ItempBP -> Item Type). The struct slot itself is a item object reference.
Loose Bag is a struct of struct(arrays) and can only contain loose bag type items …no weapons.
Consumables [meds/boosters/healing] (array) … stackable
Attachments (array)
Throwables (array)… stackable
Ammo (array) … … stackable