Heres my PlayerControl script
void Update () {
foreach (Touch FingerTouch in Input.touches)
{
if(FingerTouch.phase == TouchPhase.Began)
{
FingerInitialPosition=FingerTouch.position.x;
}
if(FingerTouch.phase == TouchPhase.Moved)
{
FingerMovedPosition=FingerTouch.position.x;
if(FingerMovedPosition>FingerInitialPosition)
{
charcter.transform.Translate(Vector2.right * speed * Time.deltaTime);
}
if(FingerMovedPosition<FingerInitialPosition)
{
charcter.transform.Translate(-Vector2.right * speed * Time.deltaTime);
}
}
if(FingerTouch.phase == TouchPhase.Ended)
{
FingerInitialPosition=0f;
FingerMovedPosition=0f;
}
}
}
}
The problem here is the player doesn't move when you swipe and hold on the touch screen but only moves when you keep swiping.
Can you please help whats wrong or missing in the code so that the player moves when swiped and held?