I have an actor component which is for a player’s inventory, but I have all the basics done like adding, removing, finding, and if the player has the item but I need update the logic after its added or removed based on the quantity, and to check the quantity of the items the player. I just don’t know how to go about that.
Help Needed?
Hey there @MARZ64331! Someone making a suggestion would need to see the blueprint/code to understand best how to go about it.
From a high level, an effective way to handle inventory item count (presuming you’re using a data structure as an “item” in the inventory) you would use your find function to check for the item already in your inventory, check how many there are, the item’s maximum possible count, then add however many to that slot, if not move the rest to another empty slot. Following the same logic but in reverse for taking out an amount.
This is for adding but I think that if I get the info for how to do this based on quantity then I should be able to handle the removing and if the player has the item by myself as I just need a push in the right direction.
If I understand you correctly you may get the amount of items in your inventory by using the “lenght” node on your items array. If you want to store the amount of every single item you may implement a counter or use a struct instead of an array by changing the type of the variable. A struct is like an array with one unique entry and one not-unique field belongung to it.This would allow you to have one unique entry for each item and one counter for them.
To update the logic you could call any function at the end of your adding/removing function.