Forum begins after the advertisement:

[Part 9] Dragging and Dropping?

Home Forums Video Game Tutorial Series Creating a Farming RPG in Unity [Part 9] Dragging and Dropping?

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
  • #13329

    This tutorial series is great, though unfortunately, I admit I am having a lot of trouble trying to change the inventory to be able to drag items to slots instead. I’m trying to implement a crafting system that requires you to be able to drag things and being a somewhat subpar programmer I just can’t figure this out. Does anyone have any ideas on how to approach this?


    Hi! I haven’t tried to implement this with this tutorial specifically (at least not yet), but I did use the below resources to add this functionality to some other games I’m working on that had their own inventory systems and it worked well. One video covers the drag and drop functionality itself and in the other the same person covered their inventory system altogether.

    Drag and Drop

    Hope this can help a bit! As far as the crafting itself, I’m still struggling with this myself without many resources but I’ve been able to get to a decent point referencing Brackey’s Crafty game.

    Jonathan Teo

    Hi Kiko, you can try following the tutorial as Aaliyah has helpfully linked.
    To integrate the Coco Code video into our existing codebase, you will want to create DraggableItem as a separate class to instantiate instead of doing it by transform parents (This means that you have to Destroy it once the drag operation is complete). The class would need to store information on which inventory/hand slot it came from.

    Then on the InventorySlot class, you will need to change the logic of the OnPointerClick function. You can have it clear the display once clicked, and instantiate the DraggableItem with the item it is representing loaded in.

    Finally, with the OnDrop function, you will retrieve the information needed from DraggableItem, and with the information, call InventoryManager.Instance.InventoryToHand or InventoryManager.Instance.HandToInventory depending on the data. You will also need to create a new function to handle the movement from one inventory slot to another.

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.

Go to Login Page →

Advertisement below: