Mobile equivilent of onMouseUp

I have been working with the controls for mobile devices and have the clicking working fine.
However I want to implement swipes and have a small issue of when you attempt to swipe (on the initial touch) it clicks on the initial swipe action. Since my screen is full all the time it becomes very problem-some if you click when performing a swipe.
Is there a way of having mobile devices have a onMouseUp type of detection? It might be small and I am just overlooking it.

Current code for touch:

if (Input.touchCount == 1) 		{
	    	if (Input.GetTouch(0).phase == TouchPhase.Began)
	    	{
		       Ray ray = Camera.main.ScreenPointToRay
(Input.GetTouch(0).position);
		       RaycastHit hit = new RaycastHit();
		       if (collider && collider.Raycast (ray,out hit,
100.0f))
		       {OnMouseDown();}
	   	    } 		}

Thanks :slight_smile:

Yes! Use TouchPhase.Ended instead of began.

Most “mouse down” type interaction on a touch screen is “press and hold” so there is a very slight delay between you touching the screen and the action (ray cast in your case). A swipe is a touch and move. So, if after say 0.1s the touch position has moved then you are doing a swipe, and if not then you are doing a “mouse click”.

The equivalent of a mouse up is TouchPhase.Ended.