Item Stacking + hotbar issues

Unfixingdock

New member
Hey how do i stack items when picked up in inventory and set a max stack limit?
Also when i create a hotbar and move an item from inventory to hotbar it keeps the item in the inventory as well
 
Last edited:
To set a limit to the stack size of some items you can use ItemRestrictions:

It is highly recommended to create a custom Item Restriction component such that you can choose exactly what happens with the items that don't fit.

You can also use a MultiStackItemCollection if you want multiple stacks of the same item (this has a stack limit built in which might be what you want)

The way we design item stack limits is by setting the limit as an attribute on the Item Category or the Item Definition. Then when adding an item to the collection we can check the limit on the attribute of the item and choose how much we add and how much we reject.


For the hotbar, that's how we designed our hotbar. Our hotbar is simply used as a shortcut to the item which is still in the inventory.

There are so many games that uses hotbars differently, there's no one size fits all solution.
So we recommend people to create their own hotbars exactly like they want but Inheriting the Item Hotbar script or for even more control by inheriting the ItemViewSlotsContainerBase script.

In your specific, you could have a filter on the Inventory Grid that Hides the items in the Grid when they are part of your custom hotbar. You could do so by moving the items to a diferent Inventory or a different ItemCollection. Or you could create a custom ItemInfoFilter that knows what items are in the hotbar.
Check out some of the other forum questions, some other people created custom Item Hotbars, so you might learn from them.

I hope that helps out :)
 
Top