Forum rules - please read before posting.

hotspot context sensitive default action

Hello,

I am trying to reproduce the typical behaviour of LucasArt graphical adventures. To be more specific:

  • The action on a hotspot can be "examine" or "use", but depending on the hotspot, one or another is default action and the other is the secondary one (that is triggered with the right-mouse button). For instance, in a book hotspot I want the "Look at book" to be the default action and the "pick up" to be the secondary. While if it is a door, I want "Open door" to be the primary and "look at" the secondary.
  • There are a set of buttons in the GUI that "lock" the actions of the hotspot. For instance, if the user click on "Look at", then only look at actions will be trigger when clicking on the hotspot. Once clicked, the "lock" is lost and the actions becomes "context sensitive" again.

Is there any way to achieve this or scripting is necessary? I can program, I just do not want to reinvent the wheel.

Thanks in advance!

Comments

  • edited May 2022

    Are you referring to the "nine verbs" interface of e.g. the early Monkey Island games? A (hopefully) somewhat accurate recreation of that interface can be found on AC's Downloads page.

    When your Interaction method is set to Choose Interaction Then Hotspot, you can enable the Set first 'Use' Hotspot interaction as default? option to have AC refer to each Hotspot's first-defined Use interaction as its default. This default Interaction can then be run by invoking an input named "DefaultInteraction".

    This behaviour is made use of by the above template. In your description, this would count as the secondary action - since the "regular" cursor mode is still based on the icon mode chosen by the player.

    If you wanted the cursor itself to change interaction mode based on the Hotspot you're currently over, and still make use of the above, you could feasibly handle this by attaching a custom script to your Hotspots that alters the active cursor when selecting it, e.g.:

    using UnityEngine;
    using AC;
    
    public class ForceHotspotIcon : MonoBehaviour
    {
    
        public int hoverOverIconID;
        private bool resetAfterDeselect;
    
        private void OnEnable ()
        {
            EventManager.OnHotspotSelect += OnHotspotSelect;
            EventManager.OnHotspotDeselect += OnHotspotDeselect;
        }
    
        private void OnDisable ()
        {
            EventManager.OnHotspotDeselect -= OnHotspotDeselect;
            EventManager.OnHotspotSelect -= OnHotspotSelect;
        }
    
        private void OnHotspotSelect (Hotspot hotspot)
        {
            if (KickStarter.playerCursor.GetSelectedCursorID () == -1)
            {
                KickStarter.playerCursor.SetCursorFromID (hoverOverIconID);
                resetAfterDeselect = true;
            }
            else
            {
                resetAfterDeselect = false;
            }
        }
    
        private void OnHotspotDeselect (Hotspot hotspot)
        {
            if (resetAfterDeselect)
            {
                KickStarter.playerCursor.ResetSelectedCursor ();
                resetAfterDeselect = false;
            }
        }
    
    }
    

    This script makes use of the OnHotspotSelect and OnHotspotDeselect custom events - a tutorial on this topic can be found here.

  • Thank you for the detailed explanation. I was not aware of the Downloads section!!

    And yes, I was referring to the "nine verbs" interface. I did read most of the manual, so more or less I had some idea about how to do it, but I was not aware of how "built-in Unity UI" was bound to the "menu" of the AC Settings (the reason is because I did not explore that option yet as I was not sure whether I would need it). Your proposal seems more interesting.

    Really, thank you again!

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.