Inventory/Weapon Items Set up. Best practice/idea?

Hi. I’m trying to set up an inventory system sorta like Resident Evil so weapons and items are all valid in each space of the inventory. Ive created functional weapon blue prints, attaching to a character etc. Then I thought wait shouldn’t I be doing this differently?

So currently WeaponBPs and ItemBPs are actors that “attach” to the character and are unrelated. Later down the track I would place them in inventory slots using variabled to check if I have a weapon, and counts to check if I have an item (Note ItemPB’s will not be shown on the player model but just update held item data. eg Pick Up > Update Count > Destory World Actor). With Item Functionality not in the ItemBP itself.

Or

Should my WeaponBP be a child of the Item BP so all weapons are “Items” as well so when it comes to inventory they can be arranged the same and also have the functionality of the item in the ItemBP itself.
Example: Each of the BPs are a child of ItemBP
ItemBP - WeaponBP - Individual Weapons
| — ConsumableBP - Individual Consumables
| — KeyItemBP - Individual Key Items

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

1 Like

Ok so I’m having a small issue when it comes to a system that uses ItemBP which has Child WeaponBP which has child Weapon(M416)

Here is my current pick up code.


The issue is that I am having to cast it to a WeaponBP Class in order to spawn it correctly doing this takes away any ItemBP functionality from what I can see

This is how its set up:
ItemBP: https://i.imgur.com/cHRPUPG.png

Child of ItemBP WeaponBP: https://i.imgur.com/r5fzD17.png

I’ll paste a base setup (BP) later this evening … hammered with work at the moment.

So Im having another shot at it. But cant seem to see how I can fix it.

Basically because I am casting ItemBP as a WeaponBP to access the Weapon Details which are a part of the ItemBP Child Class WeaponBP. If I can find a way to access WeaponDetails(its a structure) from the ItemBP level without having to cast the object then I can easily go on with my inventory system.

The reason I want to do this is because each inventory slot needs to be able to hold any of the children of the ItemBP class(Weapon, Consumables and Key Items) not specific slots for weapons etc. Because Inventory juggling is a keypart of the design exactly like RE.

Using my example above you’d cast to WepSK_M416.

ItemBP (parent item class): Contains data structure/vars that all items will have.
e.g. Item ID, Item Type, umg icon etc.

Weapon_SK_BP (child Item class): Contains data structure/vars and components that ONLY & ALL weapons will have.
e.g. Max ammo, recoil struct, sway, attachment system, reloading, montages, fx, sounds, camera component etc.

WepSK_M416 (child child item class): Contains data structure/vars and components that ONLY the M416 will have if any.

The structures inherited from Weapon_SK_BP are fill ins so you don’t have to build each weapon from scratch or C&P an existing and modify. By simply using “Create child BP class” from Weapon_SK_BP gives you all the format, structures and vars needed to have a new weapon. Fill in the vars/struct fields … done.

Look at as templating. Weapon SK BP is a template for weapons.

Yeah thats how I have it set up currently. My issue is when it comes to the inventory system M416 BP is a different class to Key Item class so when making the array for the inventory each slot has to be generic and accept any class. But I don’t see a generic class variable for that.

I’m setting a basic struct in the itemBP … Item ID, Item Type, Sub Type. This gets filled out in the wepsk_m416 class … (M416, Weapon, AR).

The actor on ground (item) has a collision. On begin overlap I cast to the player class and I pass the actor and the struct data via event to the player class. The character event (INVSYS Pickup) uses the struct data and switches to route for casting.

Item Type (weapon) -> Event/Function for weapon item handling -> Sub type (AR) … lots of weapons. This just breaks it down in to an easy to use/read structure. -> Then on to Item ID.

Item ID == M416 -> cast to WepSK_M416 … now you have the entire structure/data from ItemBP -> weapon BP -> wepsk_m416

I’ll post picks and a little vid tomorrow … later today (saturday).

I see your issue now. Was early morning (late for me).

Create a struct entry for weapons as Weapon_BP object reference [array]. Do this for each type of item that will be physically spawned on the character.

For the other items …say consumables you’ll still need an array, but of type that suits your project.

I’ve just about finished building out a fresh/rough demo of my projects inv sys. I’ll post a vid and bp screens in a bit.

So create a struct entry for each each item type in this case WeaponBP ConsumableBP KeyitemBP. Then build and array using these structs and that will allow for each slot in the inventory/array to be utilized by any ItemBP child at that point.