Answer the question
In order to leave comments, you need to log in
How to divide the touchscreen area into 2 parts?
Continuing the theme of management in a 2D platformer!
I connected Joystik, made it only Horizontal, everything is ok.
But I made a jump on Input..GetKeyDown(KeyCode.Mouse0) and, as it were, suits, but the whole screen reacts)))
Tell me how to split the screen into two working (not touching each other) areas?
Thanks a lot for your help. I'm gay
Answer the question
In order to leave comments, you need to log in
Let me send you some hints.
and you figure out how to split the screen in half))
https://docs.unity3d.com/ScriptReference/Rect.html
https://docs.unity3d.com/ScriptReference/Rect.Cont...
https://docs.unity3d. com/ScriptReference/Input-mou...
and to understand that it is possible to track each touch separately on multi-touch screens, check how many fingers touch the screen, etc.)
https://docs.unity3d.com/ScriptReference/Input.Get...
and finally - the screen size in pixels can be found here.
https://docs.unity3d.com/ScriptReference/Screen.html
in the end you have the screen size in pixels, the position of the touch (click) (in screen coordinates / pixels)
and a method for checking if the coordinates fall into the rectangle)
(there is also an option to hang several different buttons / sprites / objects, and fasten events to them based on the UI or send beams to check with handles, but I think the option with screen coordinates should suit you if the task is just in half)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question