Hi! I am trying to make a spaceship thrust and shoot dependant on which screenhalf I touch. I’ve made the touch work so the ship moves when i touch the left half and shoots when I touch the right half. The problem comes when I try to let go of either of them, then nothing happens unless I let go of both sides. Or in another variation, the thrust never stopped. How can I register if left half or right half was released? Currently I wrote the code so I need to let go of both, but I’ve tried so many variations and nothing works…
Here is a simplified version of my code:
public Rect leftScreen = new Rect(//position);
public Rect rightScreen = new Rect(//position);
void Update () {
if(Input.touchCount > 0)
{
touch = true;
if(leftScreen.Contains(Input.GetTouch(0).position) || leftScreen.Contains(Input.GetTouch(1).position))
{
startThrusters();
}
if(rightScreen.Contains(Input.GetTouch(0).position) || rightScreen.Contains(Input.GetTouch(1).position))
{
//Fire Weapons
}
}
if(Input.touchCount <= 0)
{
stopThrusters();
}