But player 1 and player 2 buttons cant be clicked at the same time
and I have no idea how to make it work the way I want to
I need that Touch Down/Touch up and I have no idea how to handle that with multiple touches.
If anyone can help me that would be amazing.
One approach people seem to use for multi touch buttons is EventTriggers:
I think the input does allow for multi touch - but it takes some custom settings to get it to work proper - for instance enabling multitouch through code (Input.MultiTouchEnabled = true; ) and some stuff.
And I think if you carefully manually handle touches with GetTouch you can also do multi touch setups:
EDIT: one more thing to consider - last I checked unity remote does not accept multi touch properly, and you’ll need to test a build on the actual device rather than using remote!
You’ll need to look into touch input (there are checks for touch which you would look for in Update) and not use the buttons as buttons.
I honestly haven’t tried this, but this would be my guess as I don’t believe the MouseDown and MouseUp can handle multiple touches properly.
Example would be getting a touch from the array of touches Unity - Scripting API: Input.GetTouch and then checking for when that touch ends and seeing if it entered and exited a gui element.
That is a tricky situation when it comes to scaling for all screens. There isn’t an ideal solution I’ve discovered - but you could depend on checking Screen.height and Screen.width to determine what scale you should be checking at. An alternative way might be to check with raycasts when a touch is down, and if it lands on a button, consider that a hit, here is an example of that kind of stuff: https://stackoverflow.com/questions/49321922/unity-raycast-ui-button-and-call-its-on-click-event
That might not have working code - I haven’t personally tested, but google around for stuff similar to that, and see if you can hack something together.
I’m actually not totally sure if there is way - but if so, google may know the answer
There might be some way to setup delegates to call those methods when a certain raycast hits that button - but it would be a bit overkill, as you can already tell the button is being hit when the raycast detects it - so you probably wouldn’t need it to do that anymore. I hope that makes sense
It all works fine but when I don’t release the touch and move to the side
It doesn’t really do anything till I touch again
I understand why this is happening but i have no idea how to fix it