Cant get Touch Position.x
I have a script running on the player, and I want it so that when the left half of the screen is touched, it will do something (I have the do something code). I have it so far that when you touch on the left half, it should display left, and if the right half is touched, it should display right (in the console).
Although the issue I am having is that whether i touch on the left or the right (with 1 input) the console displays both left and right?
here is the code:
for(int i = 0; i < Input.touchCount; i++)
{
Touch touch = Input.GetTouch(i);
if(touch.phase == TouchPhase.Began)
{
if(touch.position.x<(Screen.width/2)){
print ("left");
}
if(touch.position.x > (Screen.width/2)){
print ("right");
}
}
if(touch.phase == TouchPhase.Ended)
{
}
}
But instead, whether I tap on the left or right, it displays both. If I hold down one finger on the left half, it still displays both in the console, and vice versa for the right half.
Can I get some assistance please :( Its driving me insane.
Your answer
Follow this Question
Related Questions
Touch screen Input Help 1 Answer
Unity 2D Touch drag specific Object 0 Answers
Detect how long a tap is held 1 Answer
Stupid question but I have to figure out 0 Answers