Forum rules - please read before posting.

Touch screen and Choose Hotspot Then Interaction

I'm dabbling with a touch screen version of my game and need to change my interaction model quite a bit, and hit some snags anyone might have some insight into.

Current Settings:
Movement method: Drag
Input Method: Touch Screen
Interaction method: Choose hotspot then interaction

My gameplay is fairly simple. I want to have the player touch a hotspot and then show a menu of the one or two possible interactions (Examine and Use). The problem is that when I select Choose Hotspot Then Interaction, my Examine interactions disappear from their hotspot panel, so the Examine interaction can't be called from the interaction menu that I've made.

Since the Examine interaction is disabled/gone in this mode, nothing happens when I tap the Look icon. Is there a reason Examine interactions are not available with this method?

I'd also like to only show the appropriate icons (Examine and/or Use) if they are available on their hotspot. Some hotspots only have examine interactions, while others have both. I realize that my setup would probably need some custom scripting, so any pointers would be appreciated!

Unity Mac 2019.4, AC 1.71.7, iOS build

Comments

  • The "Examine" Hotspot panel is unique for "Context Sensitive" mode, as its part of the specific behaviour of that interaction method.

    When using "Choose Hotspot Then Interaction" mode, each icon available in your Interaction menu is a "Use" interaction - only each has a different associated icon. See the 2D Demo for a guided example.

    The "Examine" data is still there, but not used in this mode and so hidden from view. It should be possible through scripting - either at runtime or in Edit mode - to amend your Hotspots so that such interactions are transferred from Examine to Use. Something like:

    Hotspot[] hotspots = Object.FindObjectsOfType <Hotspot>();
    foreach (Hotspot hotspot in hotspots)
    {
        if (hotspot.lookButton && hotspot.provideLookInteraction)
        {
            hotspot.lookButton.iconID = KickStarter.cursorManager.lookCursor_ID;
            hotspot.useButtons.Add (hotspot.lookButton);
            hotspot.provideLookInteraction = false;
        }
    }
    

    As for only showing defined Interactions, that should just be a case of checking Auto-hide Interaction icons based on Hotspot? in the Settings Manager.

  • edited September 2020

    Thanks! I'll try to see if I can transfer the examine data to use interactions and make it work that way.

    Note @ChrisIceBox : There is no Auto-hide interaction icons based on Hotspot setting when input method is set to Touchscreen. Is there a way to enable this setting in touchscreen mode?

  • A little update - I got a bit closer to getting the wanted behaviour. Regarding my previous post about Auto-hide interaction icons not being available in Touchscreen mode, they are actually possible to enable by first selecting Mouse and Keyboard, doing the enabling, and switching back to Touchscreen. Hopefully they will be remembered when quitting Unity, I'll have to check.

    I also got the Examine hotspot working thanks to your suggestions:

      void Start()
         {
    
            Hotspot[] hotspots = Object.FindObjectsOfType<Hotspot>();
            foreach (Hotspot hotspot in hotspots)
            {
                if (hotspot.lookButton != null && hotspot.provideLookInteraction == true)
                {
                    hotspot.lookButton.iconID = KickStarter.cursorManager.lookCursor_ID;
                    hotspot.useButtons.Add(hotspot.lookButton);
                    hotspot.provideLookInteraction = false;
                }
            }
        }
    

    However, one unwanted behaviour is still bugging me:
    When tapping a hotspot, the interaction icons appear. But when directly tapping another hotspot, only the hotspot label appears. Only when tapping the hotspot one more time does the interaction icons appear. When no hotspot has been selected, it works as it should, it's only when a hotspot is active this occurs:

    https://imgur.com/a/uDdirmC

    (Excuse the crappy use/look icons, just for testing).

    "Can close interaction menus by tapping another hotspot" is enabled, which I hoped should mitigate this, but it doesn't. Any ideas appreciated!

  • There is no Auto-hide interaction icons based on Hotspot setting when input method is set to Touchscreen

    Thanks for the bug report. I'll address this.

    When tapping a hotspot, the interaction icons appear. But when directly tapping another hotspot, only the hotspot label appears.

    Can you share screenshot(s) of your full Settings Manager?

  • Thanks - please leave this with me for the moment and I'll attempt a recreation.

  • Recreated.

    Though, for me, unchecking "Can close interaction menus by tapping another hotspot" improves things. Is it not the same for you?

    Is in in builds or only the editor?

  • Thanks, and sorry for the late reply. Unchecking "Can close interactions..." does help somewhat (in builds - in editor the mouse over interactions messes with the hotpot label, but that's really not a big issue).

    But a problem with this is that if the player drags their finger across other hotspots, the previously opened interaction menu stays open.

    https://imgur.com/a/DohQdiD

    Preferably this should close when the finger hits other hotspots, or update to the currently selected hotspot. Not sure if this is possible right out of the box?

  • I'll attempt another recreation.

    But it may be possible to have a custom script hook into the OnHotspotSelect event to force-off the Interaction menu if it's showing for a different Hotspot:

    using UnityEngine;
    using AC;
    
    public class ForceOffInteractionMenu : MonoBehaviour
    {
    
        private void OnEnable () { EventManager.OnHotspotSelect += OnSelect; }
        private void OnDisable () { EventManager.OnHotspotSelect -= OnSelect; }
    
        private void OnSelect (Hotspot hotspot)
        {
            Menu interactionMenu = PlayerMenus.GetMenuWithName ("Interaction");
            if (interactionMenu.IsOn () && interactionMenu.TargetHotspot && interactionMenu.TargetHotspot != hotspot)
            {
                interactionMenu.TurnOff ();
            }
        }
    
    }
    
  • Thanks, I'll try this when I return to the touch screen version. A bit busy with the release of the game, but I'll return to this thread if needed afterwards!

  • Here's an updated script. Upon dragging the finger from one Hotspot to another, this one will turn off the Interaction menu, as well as re-show it if you then release the touch over the second Hotspot:

    using UnityEngine;
    using AC;
    
    public class ForceOffInteractionMenu : MonoBehaviour
    {
    
        private Menu interactionMenu;
    
        private void OnEnable () { EventManager.OnHotspotSelect += OnSelect; }
        private void OnDisable () { EventManager.OnHotspotSelect -= OnSelect; }
    
        private void Start ()
        {
            interactionMenu = PlayerMenus.GetMenuWithName ("Interaction");
        }
    
        private void OnSelect (Hotspot hotspot)
        {
    
            if (interactionMenu.IsOn () && interactionMenu.TargetHotspot && interactionMenu.TargetHotspot != hotspot)
            {
                interactionMenu.TurnOff ();
            }
        }
    
        private void Update ()
        {
            if (KickStarter.playerInput.GetMouseState () == MouseState.LetGo &&
                KickStarter.stateHandler.IsInGameplay () &&
                KickStarter.runtimeInventory.SelectedItem == null)
            {
                Hotspot hotspot = KickStarter.playerInteraction.GetActiveHotspot ();
                if (hotspot)
                {
                    Menu interactionMenu = PlayerMenus.GetMenuWithName ("Interaction");
                    if (interactionMenu.IsOn () && interactionMenu.TargetHotspot && interactionMenu.TargetHotspot != hotspot)
                    {
                        interactionMenu.TurnOff ();
                    }
    
                    if (interactionMenu.IsOff ())
                    {
                        KickStarter.playerMenus.EnableInteractionMenus (hotspot);
                    }
                }
            }
        }
    
    }
    
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.