- Home /
Problem with UI buttons and MultiTouch
I am currently making a mobile game in which the character can run, jump, and shoot. Each one of them works individually, but for some reason I can't run and jump or run and shoot. I know that my device recognizes multi-touch, because earlier I created a print test to indicate how many fingers were touching the screen. It always worked correctly, but the issue now is that the UI buttons I'm using for jumping and shooting aren't working if another finger is already down. Any ideas why? I'm using an android device and Unity Remote 4, if there's a chance that has anything to do with it.
Answer by meat5000 · May 11, 2016 at 01:15 AM
I use OnDrag to measure the offset of a panel for a joystick and a simple button for shooting. Using interfaces like IPointerDownHandler etc and the StandaloneInputModule seems to support Multitouch.
Can you explain that further? I thought the StandaloneInput$$anonymous$$odule was what I was using by default, but it isn't working for me. I can post code snippets if necessary, if the problem would be something in the code itself.
Its a slight modification of the script on this page (DragPanel)
https://unity3d.com/learn/tutorials/modules/intermediate/live-training-archive/panels-panes-windows
Implement your button using IPointerDownHandler in a script on that button. The SI$$anonymous$$odule is part of the EventSystem, which you must have for a Canvas to work at all, so I presume its there by default.
I clicked on the link and nothing showed up. Does the tutorial you are trying to link to still exist?
Answer by Highwalker · May 10, 2016 at 05:56 AM
Personally, I wouldn't use the built in ui objects for the actual controls. You might be better off using one of the many assets out there which handle touch controls, especially if you're fairly inexperienced. My personal favorite is Control Freak.
Thank you for the advice, but when I looked up Control Freak on the Asset Store I couldn't find a single free control set. I assume that's because there isn't one, and I really don't want to buy an asset package when what I've set up would work so well for what I'm doing if I wasn't encountering this bug. Do you have any idea how I could make it work without purchasing a pre-made asset from the Store? As I mentioned, the only problem is that the buttons aren't working when another finger is down. Everything else works.
Yeah, control freak certainly isn't the cheapest. But by far the best I've used. And the dude is great at providing support.
Here's a free one with good reviews. Though I haven't tried it.
https://www.assetstore.unity3d.com/en/#!/content/15233
I really don't know what's causing it to only accept one input. $$anonymous$$ight be a setting in the canvas or event handler, but I'm really not sure.
Answer by Raimi · Jun 11, 2017 at 06:56 PM
As far as I know the UI buttons use pointer, which simulates mouse clicks. That's why you cant achieve multi-touch using the default buttons. The UI is intended for menus which usually only take 1 touch at a time.
That is not true, though it's not really clear in the docs. StandaloneInput$$anonymous$$odule handles mul$$anonymous$$ch. See: https://docs.unity3d.com/$$anonymous$$anual/script-TouchInput$$anonymous$$odule.html
Answer by petanovic1234 · Jun 12, 2020 at 10:01 AM
I have the same problem Did you find solution for this problem?,Did you find solution for this??
Your answer
Follow this Question
Related Questions
Button issues since Catalina 0 Answers
UI Scaling with Button Text 1 Answer
Making an object rotate towards touch 3 Answers