Hi all! I think this is one for Chris.
I am trying to work with something that I don't know if it's a bug or expected behaviour.
I am working on a mobile game. Both my hotspot and interaction menu have an appear type of: on interaction.
My interaction menu (a 9-verb box) pops up in the center of the screen when a hotspot receives a single tap. The hotspot label pops up as well in the lower center of the screen. This is my desired behaviour.
Problem is, no matter how quick you remove your finger, it is interpreted as a finger dragging / retaining the cursor "in place" and the hotspot label updates as well. So if during those miliseconds, the spot you touched happens to have one of the 9 verbs now, the hotspot label will update as if you were actively hovering over / dragging your finger on that verb when you didn't intend to.
Example.
Let's say there's a flower. You touch it and you should get the pop up menu with 9 available interactions and a hotspot label reading "flower".
So you get the interaction menu, but it just so happens the verb "push" is at that same spot you touched. So as soon as you touch the flower, you get the interaction menu plus the label: "Push flower", which is not desired behaviour.
This is weird because I have Touch screen as the input method and "Moving touch drags cursor" is disabled (I actually don't see a difference at all when enabling / disabling this, other than my inventory not opening properly when drag is enabled).
I think if I could actually disable the drag cursor completely, this will be resolved. So basically have all touch be read as a single tap.
In the meantime my workaround is to reposition my interaction menu so that it pops up in the lower section of the screen, where I don't have hotspots. But I would really like to solve this so that my menu can pop up in the center without any interference.
Any ideas?
Thanks in advance!!!
It looks like you're new here. If you want to get involved, click one of these buttons!
Comments
Hi, same problem to me with the AC menu. When i click on Language it change when touch and change when my finger left the screen.
My solution is:
Try to switch in INPUT METHOD: Mouse and keyboard (and not TouchScreen). On iOS and Android it solve the question of aftertouch but if anyone have a best help, please, write below.
Thank you, @voceradio. Unfortunately, switching to Mouse and keyboard in an android build adds undesirable behaviour for me. So I'm hoping there is a way to register single taps as such.
I'm unclear about exactly what's going on. Does the Hotspot label only update when you begin dragging, or does it update just by virtue of the touch being held when the Interaction menu appears?
Is your Interaction menu rendered by AC, or Unity UI? AC menus will react to the cursor position at all times. I'm not sure about how Unity UI works in such a situation.
The cursor position, in touch-screen builds, can be overridden through use of the InputTouchPositionDelegate - see the Manual's "Remapping inputs" chapter for more.
It should be possible, through use of both this and the OnHotspotSelect event, to reset the cursor position when a Hotspot is selected, and keep it reset until the touch is release.
Something like this:
https://paste.ofcode.org/uHPfZ7GFgs8XijtLJ6SXiK
I don't have to drag. It happens if I tap as well. It's like taps are being interpreted as tapping and "holding" (dragging). Since dragging behaves like hovering a mouse over the interaction buttons, it updates the label if coincidentally the cursor is there. Mind you, even though "Moving touch drags cursor" is turned off, I can drag my cursor around during gameplay as well. It would be great to disable it altogether.
Unity UI.
I just added this script and tested on android. I'll try to explain exactly what happens.
1) When I tap the hotspot, I get the interaction menu as intended, and the hotspot label appears how it's supposed to (going back to my example: you tap the flower, you get the menu + the label "flower").
However:
2) When I tap the interaction I want, I don't get the hotspot + interaction label ("Pick up flower") --I even have a script to delay it for a second and it's not showing.
3) More importantly, once you tap on a hotspot, the game becomes mostly unresponsive to taps whether you're tapping a hotspot or something else:
If I tapped on "talk to man", it opens the conversation, but then doesn't respond to taps.
Same thing with other interactions, I can just tap one, it follows through, but then it ignores further taps.
I can tap the menu button, but then it does not respond when tapping options.
I can tap the inventory button, it responds, but shows the label for the last hotspot instead of current inventory item.
Ah - my mistake. The InputTouchPositionDelegate is only called if the Touch Count is non-zero.
Try this:
https://paste.ofcode.org/37shJzKrn3qaECL6qpBXyhU
Amazing, Chris. Tested it on android and it works. Thanks a lot!
Hi Chris, I'm just bumping this from the other thread. This is the solution that somehow is no longer working after fixing the other issue with combining items
(You advised me to create an eventsystem prefab with a OptionalMouseInputModule component)
After I did that, the cursor does not reset position after touching hotspot.
Between the two issues this is minor, because it does not affect gameplay, but probably you have an idea as to why this happens?
Thanks in advance!!
I'm getting a 404 on the code I wrote above. I don't have a backup of it - can you share it below?
Also, what is the result of using the following instead of OptionalMouseInputModule:
https://paste.ofcode.org/325S6xeUbcNfL6x9Z8cdbpQ
This, too:
https://paste.ofcode.org/3bBKMB54HmZ4G2uqq5TYV7i
Sorry Chris, I got tied up with work this past week and didn't get a chance to go back to this. (Now it looks like with the coronavirus situation I will be out of work for a while, so more time for my game!). I wanted to try the code but it's no longer available. Do you still have it? I will also post the code you were asking about. Thanks a lot!!!
Sorry, I didn't realise those would expire so soon.
OK, first one:
Second one:
That said, I'm not 100% sure this is the direction to take. I'll see if it's possible to solve the other thread's issue without resorting to a custom module.