Thumb touch and move and collide to an object

Hello,

I am a beginner in unity, but a web developer.

My question is: Can I touch and move my finger, and this finger to hit an object. So a collision detection with my finger and an object. Can this be done in Unity?

Thanks in advance

Make any bool that is false, this bool will used to keep track of the OnCollisionEnter function like…

bool variablename = false;
	void OnCollisionEnter(Collider other)
	{
		if(other.gameobject.name=="yourHitGameobjectName")
		{
			variablename = true;
		} 
	}

and then use this variable in case TouchPhase.Moved as shown below

{
	
	// Use this for initialization
	float minSwipeDistY = 0;
	float minSwipeDistX= 0;
	
	private Vector2 startPos;
	
	void Update()
	{
		//#if UNITY_ANDROID
		if (Input.touchCount > 0)
		{
			Touch touch = Input.touches[0];
			switch (touch.phase) 
			{
			case TouchPhase.Began:
				
				startPos = touch.position;
				
				break;
				
				
				
				
			case TouchPhase.Moved:
				
				if(variablename)
				{
					//DO YOUR TASK
					variablename=false;
				}
				
				
			case TouchPhase.Ended:
				
				float swipeDistVertical = (new Vector3(0, touch.position.y, 0) - new Vector3(0, startPos.y, 0)).magnitude;
				
				if (swipeDistVertical > minSwipeDistY) 
				{
					float swipeValue = Mathf.Sign(touch.position.y - startPos.y);
					
					if (swipeValue > 0)//up swipe
					{
						Debug.Log(swipeDistVertical);
						Debug.Log("Up swiped");
					}

					else if (swipeValue < 0)//down swipe
					{
						Debug.Log(swipeDistVertical);
						Debug.Log("Down swiped");
					}
				}
				
				float swipeDistHorizontal = (new Vector3(touch.position.x,0, 0) - new Vector3(startPos.x, 0, 0)).magnitude;
				
				if (swipeDistHorizontal > minSwipeDistX) 
					
				{
					float swipeValue = Mathf.Sign(touch.position.x - startPos.x);
					
					if (swipeValue > 0)//right swipe
					{
						Debug.Log("Right swiped");
						Debug.Log(swipeDistHorizontal);
					}	

					else if (swipeValue < 0)//left swipe
					{
						Debug.Log(swipeDistHorizontal);
						Debug.Log("Left swiped");
					}		

				}
				break;
			}
		}
	}
}

Maybe this could help you…