Hi everyone, I am finishing a pong game in unity, I’ve found a little problem with the Input of the Control in the screen, (it’s for a game in mobile phones). I’ve used the tutorials of unity lesson for use a array by control the differerent touches of different fingers. I want to do a multiplayer mode when the people can play in the same device in the same screen, I can’t do it because the scrips detect like the same object (i have two scrips one for each one). Anyone know how can i do this? Thank you
Hi @Xesus
You’ll need to separate the controls of your script. The best method is to probably to separate their areas of control, such that if you tap in the top half of the screen P1 moves to that location, and if you tap the bottom half of the screen P2 then moves.
In code you’ll basically detect the touch, and then determine the Y position, and if it’s positive it’s the top and then if negative it’s in the bottom half (this is assuming that Y pos is 0 in the middle of the screen).
The alternative is to use input.touchCount == 1 to mean move P1 and input.touchCount == 2 to mean P2, but that probably won’t feel as good, and could easily let players troll each other.