Forum rules - please read before posting.
Tech questions during the weekend? Drop in on the community Discord channel!

Touchscreen: Hotspot label behaviour and tapping vs. dragging

2 very simple behaviours that can be improved for touchscreen.
(I have implemented workarounds tweaking things a little bit with Chris's impeccable assistance, but in the end it's not 100% what I had in mind).

-When choosing touchscreen as the input method in settings manager, the Hotspot menu behaves the same way it does with Mouse and keyboard, but that's a problem on touchscreen because without hovering, you don't get the full "verb + object(s)" label, which just pops up in a single frame once you finish the interaction and then reverts back to whatever hotspot you interacted with.
Just to give you an example, the hotspot label on mobile behaves likes this:

Tap ball: you get "ball" and the verb box pops up
Tap "pick up" on the verb box: you get "pick up ball" for a split second before it goes back to "ball".

I have verified that this happens on the 2d demo as well, using v.1.70.2, on hotspot then interaction and interaction then hotspot.
I have a few scripts basically using a global variable to store the last label (since it reverts to "ball" as soon as you finish an interaction), a copy of the hotspot menu that shows the stored label (can't use the original menu, since it already reverted, and can't override it with my variable, since I'm already in a OnHotspotInteract or OnInventoryInteract event). My workaround works so far, but it's quite messy, and if something changes in AC's scripts in the future, this may not work anymore.

-Second issue is the "aftertouch" (the very short time your finger rests on the screen when you tap), which is interpreted as the beginning of a drag gesture, when it is just a tap. The problem with this is that if you tap and coincidentally your finger is on a button that just popped up, then AC will interpret that as you hovering over it. That may be because of the way it reads drag gestures, or the fact that input on menus is still being read and interpreted the same way as with keyboard + mouse input. With Chris's help I reset the cursor's position when Interaction pops up.

I hope I managed to explain this clearly. I am mostly a beginner with Unity.

I would love to have these behaviours integrated into future versions of AC.

Comments

  • What's the exact behaviour you're looking to achieve with regards to the first issue?

    As for the second: I'm not sure this is related to any "drag" behaviour, and this is as much related to Unity UI as it is AC.

    The script covered in your other thread can likely be made more "generic" for use with other Menus, but I suspect that adding a transition may help the issue - since it appears to be based on the fact that tapping a Hotspot turns on the Menu in the same frame.

    Using a Unity UI for the Menu allows you to rely on an Animator for the transitions. This could be used to simply control the "Interactable" state of a Canvas Group component for a moment, rather than actually altering its appearance.

  • What's the exact behaviour you're looking to achieve with regards to the first issue?

    In regards to the first issue I wonder if AC + touchscreen could implement a way to show the full hotspot label when you tap ("Pick up ball" / "Give ball to John") in a way that you can read it (making it linger a second, like I did, or just making it stay on like the hotspot label does when its appear type is "during gameplay"). Of course this is not needed on windows builds, since hovering the pointer over hotspot or icon already gives you this full label, but in mobile builds you lose the opportunity to read it.

    As for the second one, great alternatives. I'm gonna try them. Good to know it's related to Unity UI as I am still learning and had no knowledge on how touch is handled internally, I think I was expecting it to register taps discreetly, in a similar way to mouse clicks. I'll have to read more about it.

  • edited February 3

    In regards to this, I wanted to add that I can actually drag my cursor in the mobile build (and then it behaves like a mouse hovering over screen elements), even though "Moving touch drags cursor" is turned off. I don't know if this is a bug.
    So to sum it up basically that would be my second suggestion, if feasible in the future: an option to disable cursor dragging on mobile builds.

  • I wonder if AC + touchscreen could implement a way to show the full hotspot label when you tap ("Pick up ball" / "Give ball to John")

    Best to rely on custom scripting, here, as the behaviour does sound quite specific.

    The full Hotspot label (verb included) can be retrieved within a Hotspot's class with GetFullLabel:

    myHotspot.GetFullLabel (Options.GetLanguage (), cursorID);
    

    A reference to the Hotspot to read from can be stored by hooking into the OnHotspotSelect custom event. This could be used to e.g. update a String variable text that is used in a Label menu element's display:

    int stringVarID;
    
    private void OnEnable ()
    {
        EventManager.OnHotspotSelect += OnSelect;
    }
    
    private void OnDisable ()
    {
        EventManager.OnHotspotSelect -= OnSelect;
    }
    
    private void OnSelect (Hotspot hotspot)
    {
        string newLabelText = hotspot.GetFullLabel (Options.GetLanguage (), cursorID);
        GlobalVariables.SetStringValue (stringVarID, newLabelText);
    }
    

    I wanted to add that I can actually drag my cursor in the mobile build (and then it behaves like a mouse hovering over screen elements), even though "Moving touch drags cursor"

    As in, the cursor is never underneath the finger, so that different tap positions cause it to snap - but is dragged instead, so that it never snaps?

    I can't recreate such behaviour. Try removing any custom scripts to discount them having an effect, and let's see your Settings Manager.

  • edited February 4

    Since I use hotspot then interaction, instead of OnHotspotSelect I use OnHotspotInteraction to retrieve full label, store it and show it, and then some adjustments I found necessary. But that's the thing, without custom scripting like this, you miss the written verb, which can aid new gamers that don't know a cog icon means "use", for instance. I understand that this is specific to mobile and hotspot then interaction (since the reverting back to the sole hotspot label is expected when using "interaction then hotspot"). Just throwing this out here to let you know and maybe future consideration.

    As for the dragging cursor, it does snap, but it also "drags" beneath my finger, which I now understand is expected behaviour. (again, sorry I had a hard time understanding that touch is not handled like discrete mouse clicks, so that is probably it).

    Sorry I made it this long, I am still learning Unity, C# and English is not my first language, so I always want to make sure I make sense when communicating issues or questions.
    FWIW not only I learn and find new ways to use AC, but using AC, trying new things and using the forums, instead of keeping me away from coding, actually helped me learn and improve a lot more than reading dozens of books. Events, for instance, I never fully understood from books until I had to use them in AC. So thank you!

  • Thank you for the feedback.

    One other feature I should make you aware of, though, is the Trigger interaction by releasing tap? option in the Settings Manager. With this, you can select a Hotspot and run an interaction with a single touch - with the Hotspot+Verb label showing while the touch is active.

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.
Do NOT follow this link or you will be banned from the site!