Forum rules - please read before posting.

Ability for dragged objects to stay in place after drop in 2D Drag and Drop Puzzle template

Hello AC'ers!

First off, using AC 1.74.2, and Unity 2021.1.22f1. Also, all of the menus are Unity UI.
Also, it may be important to note that the "Interaction Method" is "Choose Hotspot Then Interaction".

Am considering using the 2D drag and drop template from the AC "Downloads" section as it runs an ActionList after a correct completion -- which is needed for a new puzzle idea. The puzzle involves dragging a semi-transparent map over another map below it, and pinpointing a specific location when it's dropped in a correct spot. Then an ActionList would run.

Question: With the 2D drag and drop template, is there a way to drag items, then when the mouse button is released the "draggable item" remains in that same place instead of snapping back to its original position -- while also keeping the snap to the correct "slot hotspot / drop target" behavior?

From my understanding the 2D Drag and Drop puzzle leverages the Inventory's settings and corresponding behaviors -- as it uses associated Inventory items.

Here's an image of the full Inventory settings that are in the game currently:
https://imgur.com/a/wjrUw7C
Understandably, these two options mainly affect the Inventory items' current behavior:
-Right-click active item: Deselects Item
-Left-click deselects active item?

It would make the experience feel more smooth if the 2D Puzzle template could be modified for a dragged item to stay in the same spot wherever it was dropped.
The 2D Drag and Drop Puzzle template is great as it runs an ActionList after an item is dropped in the correct slot hotspot -- it just needs that one more thing to be perfect for this new puzzle idea!

Are there any thoughts or ideas regarding this? Any assistance would be very appreciated!

Comments

  • edited October 2021

    It would make the experience feel more smooth if the 2D Puzzle template could be modified for a dragged item to stay in the same spot wherever it was dropped.

    I think that's a fair suggestion - I'll see what I can do.

  • Thank you! It's really appreciated!

    There was just one other thing: Is there a way to change the size of the draggable item (Inventory cursor) only temporarily during the drag and drop puzzle (e.g. just when the draggable pieces are being dragged. Or in a specific scene just for the puzzle)?

    I know that the "Inventory Cursor" -> "Inventory Cursor Size" setting is used to change the size of the Inventory cursor when a normal Inv. item is selected and dragged.
    Though as the 2D Drag and Drop puzzle leverages the Inventory's cursor settings and associated Inventory items, it also changes all the other regular Inventory item/cursor sizes.

    The drag and drop puzzle / interaction will look a bit like this (keep in mind it's not finalized yet -- this is just to give a general idea):
    https://imgur.com/a/H8PgTkQ

    A semi-transparent map on top will be dragged across until it snaps into its correct hotspot place on the bottom map with different geologic details.

    In order for this to visually work, the top draggable map needs to be at the same size when it's being dragged as it is when it's in its "dropped" state". Increasing the "Inventory Cursor Size" appears to work for this, except for the issue mentioned above.

    Would really like to use the 2D Drag and Drop puzzle template for this as it allows an ActionList to be run after an item is in the correct slot hotspot -- to run a dialogue line, set a "puzzle completed" variable, and change the scene.
    I realize I could likely create my own drag and drop interactions in vanilla Unity, though was hoping to utilize AC's drag and drop puzzle template and keep as many things as possible in AC for the ActionList reason.

    In any case, thanks again for adding the feature for a dragged item to stay in the same spot wherever it's dropped. It was needed overall, and is useful!

  • Any Manager field value can be updated at runtime through script. To access it, right-click the field's label and copy its API reference. In the case of the Inventory cursor size field, it's:

    AC.KickStarter.cursorManager.inventoryCursorSize
    

    You can use this in a custom script that sets it to a temporarily value while active:

    using UnityEngine;
    
    public class SetInventoryCursorSize : MonoBehaviour
    {
    
        public float tempSize = 0.1f;
        private float normalSize;
    
        private void OnEnable ()
        {
            normalSize = AC.KickStarter.cursorManager.inventoryCursorSize;
            AC.KickStarter.cursorManager.inventoryCursorSize = tempSize;
        }
    
        private void OnDisable ()
        {
            AC.KickStarter.cursorManager.inventoryCursorSize = normalSize;
        }
    
    }
    

    Place this in the "drag puzzle" scene and configure its Inspector, and you should be able to set the Inventory Manager's value to what you want it to be normally, while the script will apply its own value of the duration of that scene.

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.