communicate with my BP after putting it in my inventory

Hello, I have come to call for help on an element that is blocking me, in my project until now the player had an ax (directly attached in the bp player) and it could attack thanks to logic (in the bp player)
I changed the approach to the game and now the player has to find the axe, so I set up an inventory system only with 5 slots visible on the screen, everything went well for the game system. inventory but problem now when I find and pick up an ax I can’t figure out how to get the player to communicate with the BP Ax he has just picked up and tell him to carry out the attack logic (previously it was the static mesh in my player plan so I didn’t need to make them communicate) thank you in advance and have a good evening

1 Like

Where is Inventory Stored? Character/Controller/PlayerState etc.
What is the variable type in inventory for the Axe?


My setup uses an Actor Obj Reference for the Loot Item type. Only if the type has a mesh that will at some point be attached to the character, OR has execution logic.

Each Type that matches the above description/use case has a Parent class.
e.g. Weapon (gun), melee (knife, axe), Grenade (frag, smoke etc)

In inventory I have an actor obj ref variable for each slot which is represented by a variable.
example:

  • Weapon 1 (weapon class Actor obj ref)
  • Weapon 2 (weapon class Actor obj ref)
  • Weapon 3 (weapon class Actor obj ref)
  • Grenade (grenade class Actor obj ref)
  • Melee (melee class Actor obj ref)

When I pick up an asset I pass a reference an set the inventory variable.

When I equip a weapon I pass a reference from the specific weapon to set CurrentWeapon var.

image

When I input an Action to have the weapon do something I check if CurrentWeapon is valid then call an event in CurrentWeapon to execute.

1 Like

Hello so the inventory is an actor component attached to the player, I have a database (Dt_inventory)



which constitutes everything that I can pick up for the moment including the axe
and I have my BP_Pickup with which I place in my world and which I defined using an id so that it becomes the actor in question


I followed a tutorial which I more or less understood…
in the project the ax will be the only weapon that I will pick up afterward it will mainly be objects which will be used for various things or puzzles, I am quite a beginner, I have not understood where to execute your shooting logic?

Here’s a more granular look at my inventory setup.

I’m using an “Assigned Slot” base inventory structure. Inventory itself is a collection of variables and functionality built in an Actor Component. The Actor Component is in the Player State class.

Items that are only Data once picked up are stored in a multi-dimensional struct. Basically a struct of structs.


For picking up items I use a BP_WorldItem Parent class that utilizes Gameplay tags (C++ implementation) to easily identify the item. I use Data tables to configure the WorldItem and the picked up reconstructed item (where applicable… weapons, gadgets, grenades etc).

A lootable item in the world is assigned an ID (GP TAG). When I interact with it (pickup) I get the ID and determine the item type (weapon, gear, meds, ammo etc) and call a specialized function for that type to handle adding it to inventory.

For example Weapons have specific slots. I can only have 1 per slot. So I have to check if its occupied and handle the response accordingly. Like replace the current with new, if currently equipped attach to hand, otherwise attach to characters back or backpack depending on if there is a back pack. The dropped (replaced) weapon gets destroyed and a BP_worldItem variant is spawned on the ground.

My setup is multiplayer so all of this happens on the server vs local client.


The weapons actors are fully coded items. Meaning all the logic for firing the weapon is located in the Parent actor class. This applies to any item that has logic. e.g. grenades, C4 [gadget], deployable shield, etc.


When I equip something, place it in the hand, I set a Equipped bool, then set the CurrentXXXXX var that represents the Type of item. (Weapon, Grenade, Melee, Gadget etc).

When I un-equip an item I set the Equipped bool false and the representative CurrentXXXX variable to Null.

Each usable item type has a dedicated Input event in Enhanced Input (IMC).

  • Weapon Fire, Weapon Alt
  • Grenade Throw, Grenade Cook
  • Gadget Use
  • Melee Attack, Melee Alt Attack

When I call the input I check if its “CurrentXXXX” var is valid and that Equipped is true.
If So I use the CurrentXXXX var reference and Call its “Action” function.
e.g. Weapon Fire, Grenade Throw/Cook, Gadget Use etc.

Hopefully this clarifies things a bit more.

1 Like

thank you very much for your response and for sharing screens it is often a little clearer for beginners. I have roughly understood how your inventory system works, however mine is much less advanced. I wonder if there are any other solutions apart from this one?

The complexity in yours will build over time. As you develop further you’ll be back in it refactoring to accommodate new items and functionality.

Best piece of advice I can give you at the moment is to step back and fully scope out your project. Build a comprehensive list of all the items and types you want or think you’ll have. Sort each item into a group type. Define the functionality of each type and how it impacts the structure of your inventory. Then define your inventory rules. Once you have all of this the How to design/build and the Why’s will stick out a bit more.

For example your Axe would to me be grouped as a Tool. To attach it I need to spawn an Actor. I’ll need to store a reference to that Actor (Actor obj ref) for when I decide to un-equip or drop it from inventory. So I’d have a variable EquippedTool (Actor Obj Ref). If the Tool has its own logic/events/variables that the controller or character needs access to then EquippedTool would need to be a type cast obj ref… EquippedTool (BP_Axe Obj Ref, or BP_Tool obj ref)

Definitely take advantage of class inheritance here. It’ll help immensely.

1 Like

I thank you for your valuable advice and I will return to work, thank you for taking the time :grinning: