Forum rules - please read before posting.

Draggable inventory when using "Choose Hotspot then interaction"

I am using "Choose Hotspot then interaction" interaction method, which works well to give a Broken Sword type style for icons to appear when you click on a Hotspot. Great stuff. However once an object is in the InventoryBox then I cannot drag it over a Hotspot to use it (again Broken Sword style), even though I have the drag and drop inventory interface option set. Instead it shows the inventory item as an icon to use against the intended Hotspot.

If I use "Context Sensitive" interaction method, then I can drag the inventory item from the InventoryBox over the Hotspot to trigger the use option. But then I don't get the icons I want by using "Choose Hotspot then interaction" interaction method.

So how can I replicate the Broken Sword style, where objects in the scene have interact icons when you click on them, but objects in the inventory can be dragged over other items in the inventory plus items in the scene to invoke a interaction (ie. the user action)? I assume it's either use "Choose Hotspot then interaction" and then use another option to allow inventory to be dragged over other object, or use "Context Sensitive" and use another option to turn on interaction icons. Note much like Broken Sword I don't need interactive icons once in the inventory, single tap would get a description, and then dragging would move it to use with another item in the InventoryBox or in the scene. And the inventory item icon against the Hotspot (current functionality) wouldn't show.

Comments

  • Welcome to the community, @Crivens.

    What are your AC/Unity versions, and what is the behaviour when clicking inventory item icons in the Inventory menu?

    The Interaction method setting should be primarily based on how you want Hotspots to be interacted with. Leave it as Choose Hotspot Then Interaction for Broken Sword-style interactions by way of an "Interaction" menu that appears when clicking a Hotspot.

    The presence of Inventory items inside this Interaction menu is optional. To remove them from view, select the Interaction menu inside the Menu Manager, and remove / hide the InventoryBox element inside it.

    For items to be selectable as they would be in Context Sensitive mode, make sure your Settings Manager's Inventory interactions field is set to Single.

    Items should then be selectable in the Inventory menu, for use on Hotspots - provided that you haven't assigned them a "Use" interaction, in which case left-clicking them will cause that to be run instead.

  • Thanks Chris. Pleased to be here!
    I am using AC 1.73.6 with Unity 2021.1.5f1.2398 personal.

    Changing "Inventory interactions" field to "Single" has almost done the trick thanks!

    Now I have the BS icons when you click on them in the scene, but can also drag the item out of the InventoryBox to use on another object. Great stuff.

    Couple of questions though:-
    1. Before I switched the "Inventory interactions" to "Single", I could examine an object in the InventoryBox using the look icon. This no longer works. I'm not bothered about an icon, but for true BS style then will need it to examine an object if I single click it in the InventoryBox, and dragging uses the object with hotspots as it does now
    2. Dragging an InventoryBox object over a different scene object will trigger my "Use" interaction, and nicely show the "Use object1 on object2" text, but if I do the same thing when both objects are in the InventoryBox then nothing happens, even though the text is the same as the previous example. Do I need a different interaction for objects in the InventoryBox, or is there a setting to inherit the scene interaction if an inventory version doesn't exist?
    3. Much like BS I have an inventory that opens when an icon is clicked (like a bag icon in BS) and then stays there as you play. Clicking the icon makes it disappear. However if the inventory is open and I pickup an object from the scene, then the whole inventory interface (close button, arrows, and InventoryBoxes) flashes for a second before redrawing with the picked up object. Don't know if this is a bug or the way I have implemented it

    Thanks for the help Chris, great stuff you answered so quickly too!

  • for true BS style then will need it to examine an object if I single click it in the InventoryBox, and dragging uses the object with hotspots as it does now

    Under Inventory settings, set a small (but non-zero) Minimum drag distance value, and then check the Clicking an Item without dragging Examines it? option that then appears beneath.

    Do I need a different interaction for objects in the InventoryBox, or is there a setting to inherit the scene interaction if an inventory version doesn't exist?

    Inventory-to-inventory interactions are defined as "Combine" interactions in an item's properties.

    For an item you want to be able to use with another, view it in the Inventory Manager and click Add combine event. This'll let you assign an ActionList as well as which item it combines with.

    To have the interaction work both ways (i.e. "Use ItemA on ItemB" also works as "Use ItemB on ItemA"), check Combine interactions work in reverse? in the Settings Manager.

    if the inventory is open and I pickup an object from the scene, then the whole inventory interface (close button, arrows, and InventoryBoxes) flashes for a second before redrawing with the picked up object

    What's your Inventory menu's Appear type set to? If During Gameplay, then it'll turn off automatically whenever you're in a cutscene. This includes ActionLists that block gameplay only for a single frame.

    You can either prevent an ActionList from blocking gameplay be setting its When running property to Run In Background (see the Manuals "Background logic" chapter for more on this), or set your menu's Appear type to Manual for complete control over when/how your menu is shown.

  • Fantastic stuff. All works well now in a very BS way. :smile: Plus I set all my interactions to run in the background and now the inventory is rock solid when picking up or examining objects. I am using "During Gameplay" with a custom icon appearing all the time with the usual items (arrows, Inventorybox) not visible. Tapping the icon toggles the other items appearing or disappearing.

    Thanks for the help Chris!

  • Now I have my interactions to run in the background and the inventory no longer flickers. But if I use a dialogue then I have to use pause along with appropriate settings to allow the user to tap to continue after reading the text. If I use run in background along with wait for the user to click settings then the dialogue will disappear on it's own when it's finished printing to the screen.

    I don't really mind using the pause option to allow dialogue to stay on the screen until the user taps to continue, and this causes the inventory to disappear until the dialogue disappears, but is there a way to allow "Run in background" so the inventory stays on screen and still allow the dialogue subtitles to only disappear after a user tap?

  • You could conceivably set a very high Minimum display time (s) value in your Speech Manager, but not indefinitely - a key distinction of background speech vs regular speech is that it must be able to end without user input.

    The other option would be to set your Inventory's Appear type to Manual, and then turn if on/off via script. Through code, you can hook into the OnEnterGameState custom event to begin a countdown whenever you enter the Cutscene state. Then, if the game remains in this state for a minimum time, have the Inventory menu turn itself off.

    Something like this should do it:

    using UnityEngine;
    using AC;
    
    public class CutsceneInventory : MonoBehaviour
    {
    
        public float minCutsceneTime = 0.4f;
        private float timer;
    
        private void OnEnable () { EventManager.OnEnterGameState += EnterGameState; }
        private void OnDisable () { EventManager.OnEnterGameState -= EnterGameState; }
    
        private void Update ()
        {
            if (timer > 0f)
            {
                timer -= Time.deltaTime;
                if (timer <= 0f)
                {
                    PlayerMenus.GetMenuWithName ("Inventory").TurnOff ();
                }
            }
        }
    
        private void EnterGameState (GameState gameState)
        {
            switch (gameState)
            {
                case GameState.Cutscene:
                case GameState.DialogOptions:
                    timer = minCutsceneTime;
                    break;
    
                case GameState.Paused:
                    PlayerMenus.GetMenuWithName ("Inventory").TurnOff ();
                    break;
    
                case GameState.Normal:
                    timer = 0f;
                    PlayerMenus.GetMenuWithName ("Inventory").TurnOn ();
                    break;
    
                default:
                    break;
            }
        }
    
    }
    
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.