Hello!
My inventory (I made from the wonderful Ryan Laley's tutorials) items work wonderfully when I use them, I started working on the drag and drop function followed by a gentleman from youtube named Karan Parmar. The drag and drop function works as expected but I had 2 problems with it. I tried fixing the two issues, thankfully I eliminated 1 problem, but the current issue I am having now is when I drag and drop an existing item into another existing item slot, it overwrites an existing item and deletes it completely.
My question is, how can I eliminate this problem and move on with finishing off my inventory? I will attach some pictures associated with my On Drop Function, and my Slot Swap function.
Thank you so much!
Uploading: slot swap problem.png…
I’m not sure exactly what’s the problem, but you may wanna input “Source Swap” and “target swap” indexes into the function? Because in your screenshot it will be always 0 if it’s otherwise not somehow stated in the function itself.
On the other note, you may wanna track whether the slot is empty or not by a boolean for example, and run “swap” operation only if “empty” is false.
1 Like
Thank you for replying!
Unfortunately, I attempted to recreate what you told me, and somehow it still does not work, the item still overlaps the existing item. I may delete the drag and drop coding and try to code it all over again from another video tutorial. Below are the recent pictures of the situation.
From what I see right now - you don’t state anywhere the “is empty” to be false. The chain logic should be: Check Drag and Drop Operation > Check If Your slot is empty (you already do that) > If it is empty - freely drop the info from drag and drop operation and set the slot’s “is empty” status to false. Otherwise, if your initial slot “is empty” bool is false > You run a swap function.
You also need to set the slot to “is empty” true when you detect the drag operation and not on drop. I’ll check Ryan’s tutorial a bit later to see what may be missing and come back with a more structured answer If you’ll still be in need.
Ryan Laley’s tutorials did not involve the drag and drop operation for UE4, I had only followed Karan Parmar’s drag and drop tutorial, I think that is where I got trapped because I did not follow the rest of his previous videos consisting of the inventory layout.
Here is the link to his tutorial I followed. Unreal Engine 4 - Request - Drag and Drop - YouTube
Please forgive me for not understanding your directions fully, I am somewhat experienced in UE4, but not fully. I am more of a visual learner when it comes to text directions.
I fixed it! whenever I made the slot swap function work, I was also able to properly follow Karan Parmar’s video tutorial correctly. I did not need to use an “is empty” boolean after all, but instead checked my drag operation node, use an equal (text) with an item structure break and a “make literal text” node. Then I plugged it into the branch infront of the drag operation node and copied and pasted the previous array elements, followed by my slot swap function and refresh node!
From what I see, all is good so far, but I did ask for your help and I greatly appreciate everything you did! Thank you!