[SOLVED]Issue with the Inventory System

So, I was making an inventory system for my game, and I actually used an already existing template, my issue is that, even if I copied the template, something is still wrong and when I pick up the item, it will not go into the inventory, or at least, it doesn’t show up.
v here is the code of the initialization v


v here is the code for picking up the item v

It seems you are using the template I made.
Few things you need to check:

  1. Have you created the Items object group and add all items to this group?
  2. All items should have an object variable called ‘name’ that store the name of the item, you need to set this manually in the editor I believe
  3. All items should have an object variable called ‘quantity’ that store the number of items to collect, this value should be set to 1 or higher, again need to set manually in the editor
  4. The name of each item should correspond with the name of the animations of the slots, so if you put “Cherry” in to a slot, you set the animation of the slot to “Cherry”
  5. Is it only not displayed in the inventory but does the counter go up?

Hope it helps.

In case it still does not work, consider sharing the project and I can have a look for you.

1 Like

Ok so I added the variables “name” and “quantity” and now it works, but… when I try to move the item from a slot to another, it doesn’t work

The way it works, when you click a slot, it is copy the item information from the slot in to an invisible object that constantly follow the position of the mouse. Once the information is copied in to this pointer object, we make it visible and set the slot to empty make it looks like you have dragged the object from the slot.

Once you release the mouse, it is going to check if the mouse is over an empty slot and going to copy the item information from the pointer object in to the slot and make the pointer object invisible again make it looks like you just dropped the item in to the inventory.

So, my guess is that you are missing this pointer object called “pointer_dragobject”. make sure you have that.

Also make sure this pointer_dragobject has all the same animations as the slot with the same names, so when you drag a “Cherry” from a slot, you set the animation of this pointer object to “Cherry” and the first animation is empty transparent image, this is how I decided to make it invisible.

1 Like

oh yes I have all of this, it actually works the first time, but when I try to move the item again, it doesn’t work anymore :frowning:

The pointer object store the name of the item in an object variable called “nameofitem”. When you drop an item, do you reset this to an empty string? nameofitem = “”

This is the events when you drop an item in to a slot:

this is the specific event that could create this bug if you forget to do it:

1 Like

sorry for my late replies, I don’t think that this was the issue as it is just like yours, or maybe I’m wrong.
Here is a link to download the project folder:

If you want to contact me directly my Discord is DangoHz#8369, and I use the same name on every social media.

When you drop the item you set the item name of the slot to be InventorySlots.VariableString(nameofitem)

Because it is invalid item name, the next time you try to drag it, the number of item in the inventory is 0 and so the events to drag the item not going to execute because as far as the events concerned the inventory has 0 items with that name and there is nothing to drag.

So you want to replace this event here:

with the expression:

PointerDrag.VariableString(nameofitem)

To copy the item name from the pointer in to the slot. And then you can drag it again :slight_smile:

If there is anything else is broken let me know. :+1:

2 Likes