Forum rules - please read before posting.

Click-and-hold on hotspot to make a Verb Coin appear

Howdy! I'm building a verb coin type interaction style.
So far I can correctly click on an hotspot, and choose (with a Curse Of Monkey Island verb coin style) one of the actions (Use, Talk, Look at).
So far so good!
Unfortunately, I want to do the same with the objects in my inventory (I'd like to use the verb coin with the objects in the inventory, while still keeping the inventory open).
This behaviour at the moment collides with being able to singleclick on an object in order to use it into the scenery.

What I want to do, in order to correct the design, is doing exactly what COMI does: open the verb coin by singleclicking and holding the mouse for a certain time (like 100 ms) on the object\hotspot, and then selecting the verb action by mouse release.

How should I approach this problem? At this time I can't see such an option in AC.

-Bosca

Comments

  • Welcome to the communuty, @Bosca.

    You can have Inventory items be treated like Hotspots (i.e. open up the Interaction menu when clicked) by setting the Inventory interactions field to Multiple.  This can be found under "Inventory settings" in the Settings Manager.  For more on this topic, see the Manual's "Inventory interactions" chapter.

    To have Interactions run when the mouse is released over an icon, as opposed to clicking an icon, check Trigger interaction by releasing click? in under "Interface settings".

    This option isn't time-based, but you could feasibly incorporate a custom script to change this setting dynamically after a set time of the menu being turned on.  The OnMenuTurnOn custom event can be used to run custom code when the menu is enabled (see the Manual's "Menu scripting" chapter), and a script reference to any Manager field can be obtained by right-clicking that field's label in the AC Game Editor.
  • Hi Chris, thanks for your answer, this helped a lot, and I'm getting almost where I want to be :smiley:
    I now have a working verb coin which executes a verb (e.g. "look") on mouse release on the Look icon. The only problem now is: I'd like to be able to open the verb coin itself by pressing the left mouse button on an hotspot and holding it down for a short period of time, so that I can release it while being on a verb icon (having the verb coin close itself if the mouse is released elsewhere shouldn't be much of a problem, I think).

    Thanks again, customer support here is heavenly!
  • To be clear: the issue is that you want to click-and-hold a while before showing the verb coin?  As opposed to showing up instantly?

    As that's not a standard option, you'll need to rely on a custom script to control the state of your interaction menu.

    In the Settings Manager, set your See Interations with field to Via Script Only.  As the message box the appears then explains, you can call a public method to enable your Interaction menu when appropriate.

    Try this:

  • Yes, that's it!
    This whole fuss was about being able to separate and implement both the single click-and-hold and the standard single click, in order to use both behaviours in the inventory (respectively to open the verb coin to do an action for an object in the inventory, and to pick up an object from the inventory and use it on the scenery).

    I really appreciated your help, thanks a lot :smiley:
  • Hi, coming back to this post since I am trying to do exactly what @Bosca explained (Hold mouse and release for interaction).
    The pasteall.org link is not working for me, just wondering if Bosca or Chris have the code at hand.

    Thank you!

  • @mad_lemon Pasteall seems to be down completely, so I'm hoping it'll be back soon. In the meantime, I suspect this is what I was referring to:

    using UnityEngine;
    using System.Collections;
    using AC;
    
    public class HoldToShowInteraction : MonoBehaviour
    {
    
        public float maxHoldTime = 0.5f;
        private float heldTime;
    
    
        private void Update ()
        {
            if (Input.GetMouseButton (0) &&
                (KickStarter.playerInteraction.GetActiveHotspot () != null || KickStarter.runtimeInventory.hoverItem != null) &&
                KickStarter.stateHandler.IsInGameplay () &&
                !KickStarter.playerMenus.IsInteractionMenuOn ())
            {
                // LMB is held down over a Hotspot or inventory item, during gameplay, and when no Interaction menu is showing
    
                heldTime += Time.deltaTime;
                if (heldTime >= maxHoldTime)
                {
                    // Open the Interaction menu
                    if (KickStarter.runtimeInventory.hoverItem != null)
                    {
                        // For an inventory item
                        KickStarter.playerMenus.EnableInteractionMenus (KickStarter.runtimeInventory.hoverItem);
                    }
                    else
                    {
                        // For a Hotspot
                        KickStarter.playerMenus.EnableInteractionMenus (KickStarter.playerInteraction.GetActiveHotspot ());
                    }
                    heldTime = 0f;
                }
            }
            else
            {
                heldTime = 0f;
            }
        }
    
    }
    
  • Thanks!
    I've selected See interactions with: Via Script Only, and created the script file on my assets, but I am not sure on how to implement it. I tried in my Interactions Prefab root object, but it doesn't seem to work.
    Almost there!

  • Ok! I figured it out (Right on the game engine if anyone is wondering).
    Now I just have to find out why "Trigger reaction by releasing click" is not working with this, and I'm done!

  • For that field to have an effect, you must either have your Input method field set to Touch Screen, or your Select interactions by field set to Clicking Menu.

    Note that this does not affect Menus rendered with Unity UI.

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.