- Home /
This question was
closed Apr 04, 2016 at 12:23 AM by
calmcarrots.
Question by
calmcarrots · Mar 08, 2015 at 02:05 AM ·
playertouchscreenmove
Player moving opposite direction when there is a new touch.
So I divided the screen into 2 spaces. Whichever side is pressed, the player will move in that direction. The problem I have is that when there is a finger on one side, and another side is touched, then the player will move to that side. I do not want this.
float h = 0f;
if (Input.touchCount > 0)
{
Touch firstTouch = Input.GetTouch(0);
if (firstTouch.position.x > HalfOfScreenWidth)
h = 1f;
else
h = -1f;
}
Comment
Answer by Manny Calavera · Mar 08, 2015 at 05:28 PM
In order to find a touch that just happened you need to iterate through all of them and find the one whose phase is TouchPhase.Began
There is an example at the bottom of the page here:
Answer by qklxtlx · Mar 08, 2015 at 08:08 AM
You should check Touch.fingerID
and Touch.phase
. When the current touch is not ended, you can just ignore other touches.