- Home /
Question by
Devangmakwana · Jul 29, 2019 at 04:01 AM ·
mobiletouch controlsball
Touch Control like in Catch Up
Game Link : Catch UP - Google Play
Basically that touch movement that a lot of popular games use where you just touch slide the object to the left and right. I want to be able to touch anywhere on the screen and slide it. Also for it not to just teleport right or left when you touch. ,
Comment
Answer by Casiell · Jul 29, 2019 at 06:52 AM
So the main idea of this movement is that you do not set players position to your finger directly. Instead you move it by the touch's position delta
Answer by rahulpatil6220375 · Jul 29, 2019 at 07:11 AM
also you can use , whenever you release your swipe then identify your touch position
private Vector2 fingerDownPosition;
private Vector2 fingerUpPosition;
[SerializeField]
private bool detectSwipeOnlyAfterRelease;
private void Update()
{
foreach(Touch touch in Input.touches)
{
if(touch.phase==TouchPhase.Began)
{
this.fingerUpPosition = touch.position;
this.fingerDownPosition = touch.position;
}
if(touch.phase==TouchPhase.Ended)
{
this.fingerDownPosition = touch.position;
this.DetectSwipe();
}
if (!this.detectSwipeOnlyAfterRelease && touch.phase == TouchPhase.Moved)
this.fingerDownPosition = touch.position;
//this.DetectSwipe();
}
}
}
Your answer
![](https://koobas.hobune.stream/wayback/20220612205649im_/https://answers.unity.com/themes/thub/images/avi.jpg)