Drag and Drop from one inventory to another

matmalm

Member
Hi, I have some issues with dragging and dropping from one inventory to another.
This is what I'm trying to do:

- In the Lobby, the player buys items in the Shop.
- Bought items go into the player’s inventory, but are not equippable.
- Before starting the game, the player can select from their inventory what they want to equip (drag and drop from one item collection to another).
- Once the game starts, the selected items are equipped.

I'm stuck in the 3rd point.
From the shop, the items go to a ItemCollection from the player just to store items the player buys, but are not equippable yet. I created 2 inventory grids; one with the player's store, and another one for another ItemCollection to drop from the player's store.
But I can't figure out how they can drop, even though both inventory grids have the drop handler and drag handler. I can drag and drop between containers from the same ItemCollection but not from the other one.
 
I will need a bit more context, as this should just work by default with no extra workaround.

Does dragging items work?
When you try to drop an Item does it show up in red to indicate you cannot add the item there?
Are you using any item restrictions?
What Drag&DropAction are you using?

Some video or screenshots would help too
 
I will need a bit more context, as this should just work by default with no extra workaround.

Does dragging items work?
When you try to drop an Item does it show up in red to indicate you cannot add the item there?
Are you using any item restrictions?
What Drag&DropAction are you using?

Some video or screenshots would help too
Sorry I couldn't post any video or pictures when I posted the thread.

This is how the UI looks and what I'm attempting to do:
See message below.-

The hierarchy looks like this: 2 panels; 1 for the items the player buys from the shop (left panel in the video), the other panel so the player transfer it to another item collection)
opsive hierarchy.png
The players inventory: where "Inventory" ItemCollection is the ItemCollection where the items go that are bought from the shop:
Also, the "inventory" is not included in the Inventory Bridge integration (with UCC), in order so the player doesn't equip it.
inventory.png

An update: now I removed a filter component from the right panel which was filtering to only show the loadout items. Now if I buy an item call it "flashlight", it will appear flashlight in both the right and left panel.
So, the issue is that the right panel is not set as a specific ItemCollection, however I couldn't find a way how to do it.

For my purpose, I still wonder if I'm in the right track.
In the lobby -> Players have the shop -> buy items and they get added to their inventory (not equippable yet) -> the player select items from that inventory to add in order to be equipped items during the gameplay (the actual game) -> the players start the gameplay with the items selected.

Note that during the gameplay, there is no UI for items, just switching between items.


An extra issue is that in the shop, to select an item I have to click 2 times, I can't show my input, so is difficult to show it, but it also happens in the demo scene integration. The previously selected item needs to be deselected in order to click another item, it doesn't automatically toggle when clicking another item:
 
I don't know what's going on. It doesn't allow me to post this link in the previous message, I feel like in the year 2003:
This is how the UI looks and what I'm attempting to do:
 
> An extra issue is that in the shop, to select an item I have to click 2 times, I can't show my input, so is difficult to show it, but it also happens in the demo scene integration. The previously selected item needs to be deselected in order to click another item, it doesn't automatically toggle when clicking another item:

That's definetly a bug, I will look into that and get it fixed before the next update

> This is how the UI looks and what I'm attempting to do:
You haven't shown me the Drag&Drop actions you are using here.
I'm assuming you haven't changed it and it is the default SmartExchangeDrag&Drop action. If that's the case then your result you are getting is expected.
The filters simply show/hide items from the relevant InventoryGrid. But that's all it does. When you drag&drop an item it simply knows that the InventoryGrid is linked to an Inventory and adds the item there. It doesn' realise you want to add an item to a specific ItemCollection.

For that you need to change the Drag&DropAction to specify exacly what you want to do. You can set a Drag&DropCondition&Action to setup some logic "CONDITION if origin is main InventoryGrid & destination is loadout InventoryGrid -> ACTION add item to loadout ItemCollection"
You would add another condition and action for the other way around too. You can have both in one conditionActionSet or you can seperate them up to you.

The DragAndDrop condition&action system is super versatile. Make sure you read the documentation and watch the tutorials on this topic:
 
@Sangemdoko

Right, that was the issue. Didn't know that the SmartExchange was preventing that, also that the Loadout doesn't show up in the UI.
Now, I got it working.

For this I was looking into the docs, but couldn't find a way to move just x1 item from the item stack from one inventory to another. If I have "flashlight" x5 in one inventory, it will move the x5 flashlights. So, without the QuantityPicker, is it a built in way to move just 1 quantity of the item instead of the full stack or has to be a custom dropAction?
 
Looks like we don't have that as an option.

You would need to write a custom DropAction or ItemAction for that. Should be fairly trivial to do, but it's preferable you do it to have more control over how your items moves cross ItemCollection
 
Back
Top