Forum rules - please read before posting.

Drag and Drop Game

edited January 2022 in Technical Q&A

Hello!
Right now im working on a little 2D Drag & Drop Game.
I was thinking of making it with an inventory, where i drag an item and drop it on a hotspot.
To this point, there is no problem, but now I also have to check on what hotspot the item was dropped so I can set a prefab at the hotspots position with the same look of the item.
I dont see any functions to do so.
Do I really need a custom script for that or is there something I miss?
Thanks in advance!

Comments

  • The regular way of running logic based on a specific combination of Hotspot and Inventory item is to create an "Inventory Interaction" on that Hotspot, and select the relevant item.

    When the item is then used on that Hotspot, the assigned Interaction ActionList will then be run - this tutorial covers the process.

    However, you may find that the "Puzzle template: Item arranging" package on the Downloads page suits you here, as it provides a few automated features such as handling the placement of dropped items.

  • Hello Chris,

    thank you, I completly missed the "Inventory Interaction" for the hotspots^^
    Also i gonna try the template, thank you :)

  • Hello again!

    So i looked into the template and right now im really struggeling on my little game.
    Sadly the template is done mostly with custom scripts, but I need a solution mostly done with ActionLists and Interactions.
    I could create a single interction for every item for every hotspot it could interact with but that seems extremly inefficient. Is there a simple way to get the exact hotsport where the item was dropped or/and the specific item that was dropped?

  • Sadly the template is done mostly with custom scripts, but I need a solution mostly done with ActionLists and Interactions.

    The scripts can be repurposed for your own game - it's a demonstration of how custom scripting can be used, but the scripts themselves can still be used if the example scene has the gameplay you're looking for.

    Is there a simple way to get the exact hotsport where the item was dropped or/and the specific item that was dropped?

    Yes - you can rely on ActionList parameters in this case.

    Instead of defining an Inventory interaction for the Hotspot, create an "Unhandled inventory interaction" instead. This will be run in the event that no Inventory interaction for the supplied item is defined.

    In that Interaction ActionList's properties, define two parameters: a GameObject named Hotspot, and an Inventory Item named Item. You can then go back to the Hotspot Inspector and assign these parameters at the bottom.

    When the interaction is run, those parameters will be assigned to the Hotspot and Inventory item involved - so you can use the same Interaction ActionList for all such Hotspots and items.

  • Nice, thank you very much!
    Again sorry for my late reply, I was busy and only could find time today to test it.
    Now I am suck using the full potential of the parameters.

    Is it possible, to assign the parameter over a different asset?
    I now have a use-Interaction with unset parameter and I want to set that parameter while running the game. How would I do that?

  • If you want to set it within the Interaction itself - at runtime - you can do so with the ActionList: Set parameter Action.

    If the value is instead fixed, and can be set in the Editor, you can attach the "Set Interaction Parameters" component to the object. In its Inspector, you can select the "Use" interaction and configure any parameter values it contains.

    For a complete list of the various components and methods available, see the Manual's "ActionList parameters" chapter.

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.