Hello everyone,I want to make a puzzle in my game similar to this one.
at 16:00The puzzle need a drag and drop function that is similar to inventory System's.
However, i dont think the papers are inventory item and i cant figure out how to do that.
Please give me some advertise,thank you.
Comments
Certainly a complex problem - I hope you're familar already with the Hotspots, Interactions and Inventory systems.
Thanks for the video, but there are some questions that the video doesn't answer. For example, what happens if the mouse is let go while not over the interactive areas?
You'll also need to describe what you've achieved so far, so that we then know which parts you need advice for.
Inventory drag-and-dropping can be enabled in the Settings Manager. It is possible to define categories for inventory items, so that you could concievably have a separate inventory just for the papers.
However, to fully recreate the video you'd be better off using Hotspots instead of inventory menus. The drag-and-drop would take a bit of custom scripting, to have a release of the mouse act as a mouse-click when an item is selected.
I would recommend that you first build the puzzle using Hotspots and inventory items without the drag-and-drop interface - and just having them as separate clicks. We can see about adding that on once everything else is in place. Each "paper" would have a sprite parented to a Hotspot in the scene, as well as an associated inventory item. The Hotspot's "Use interaction" would then move it out of view (Object: Teleport) and select it as an inventory item using Inventory: Select (this Action can be used even if it's not technically in the player's inventory).
When the paper is selected, it becomes an inventory item and can be used on the "wood" slots above which are also Hotspots. When used, you'd then de-select the inventory item and move the Hotspot/sprite representation of the paper onto the wooden slot.
To allow the papers to be re-arranged at the bottom, you'd need to make the bottom interactive area another Hotspot, and - when combined with an item - have it move the associated sprite/Hotspot to the mouse's position. This too would take a custom script or Action.
I would recommend that you begin by creating a Hotspot and sprite in the scene (parenting the sprite to the Hotspot), as well as an inventory item, for each paper. Then, paste this code into a new C# script named LinkHotspotToItem and attach it to an empty GameObject in your scene:
http://pasteall.org/697083/csharp
You can then use its Inspector to create an array of Hotspots connected to inventory items by their ID number (an item's ID number is to the left of its name in the Inventory Manager). The script also contains functions to retrieve a Hotspot linked to a given inventory item, and vice-versa - which can be used by other actions/scripts.
Let us know of your progress and we'll then help build it up from there.