moving the direction of last touch (GUITexture)

Hi. I’m working on this script to make it work for 100% for a long time and it still doesnt work as i want. What I’m trying to achieve is to move the player to the direction of last touch so its either left or right. I’m using GUITextures as buttons. The problem appear when i’m holding finger on left button (first touch) = player go left. While holding left i press and hold other finger on the right button(second touch) and player goes right. BUT - When i release the left button(first) and trying to press it again it doesnt work anymore. I’ve red many articles on internet and found that with touch.phase u can have more touches at the same time and they work. They really does in my case but not exactly as i want them. Also found they not reliable as well so I’m lost :frowning:
So below is my script. I also try something similar using the fingerId http://hastebin.com/laxeximuya.avrasm but i think that is more for gestures stuff and it doesnt seem to work as well. maybe that is not the right way of coding as im not familiar with it yet
Any help will be really appreciate. thx for reading.

for (var touch : Touch in Input.touches)
{

	if (Input.touches[0].phase == TouchPhase.Stationary && leftButton.HitTest(touch.position)){
			leftButtonActive.guiTexture.enabled = true;
			leftButton.guiTexture.enabled = false;
			goLeft = true;
			goRight = false;
			if(Input.touches[1].phase == TouchPhase.Stationary && rightButton.HitTest(touch.position)){
				rightButton.guiTexture.enabled = false;
				rightButtonActive.guiTexture.enabled = true;
				goLeft = false;
			}	goRight = true;

	}else if (Input.touches[0].phase == TouchPhase.Ended)&& leftButton.HitTest){
			leftButtonActive.guiTexture.enabled = false;
			leftButton.guiTexture.enabled = true;
			Debug.Log ("left button released");
			goLeft = false;
	}

			
	if (Input.touches[0].phase == TouchPhase.Stationary && rightButton.HitTest(touch.position)){
			rightButton.guiTexture.enabled = false;
			rightButtonActive.guiTexture.enabled = true;
			goLeft = false;
			goRight = true;
			if(Input.touches[1].phase == TouchPhase.Stationary && leftButton.HitTest(touch.position)){
				leftButton.guiTexture.enabled = false;
				leftButtonActive.guiTexture.enabled = true;
				goLeft = true;
				goRight = false;
			}
	}else if (Input.touches[0].phase == TouchPhase.Ended && leftButton.HitTest){
			rightButton.guiTexture.enabled = true;
			rightButtonActive.guiTexture.enabled = false;
			Debug.Log ("right button released");
			goRight = false;
	}	
}

I think you need to pay attention to how you read the “touches” collection, because once you let go of the first button, the [0] becomes your second finger on the screen as I recall it. I might remember this wrong as I havent tested your code. But try to log how touches[0] works in the Console or in a GUI element to learn how this collection behaves when you press multiple fingers.