Question by
pooryavosoogh · Nov 30, 2020 at 07:04 AM ·
touchphase
a simple drag and drop puzzle game , object stops following my finger if i move it fast ,...
hi there , i am trying to create a simple puzzle game , and i have a problem , that is when in my game i drag the object , if i move my finger fast on the screen fast , the object stops following my finger , but if i move it slowly it is ok , .... here is my code :
case TouchPhase.Began:
if (object1.GetComponent<Collider2D>() == Physics2D.OverlapPoint(touchPos))
{
object1ismoveing = true;//
object2ismoveing = false;//
object3ismoveing = false;//
deltaX1 = touchPos.x - object1.transform.position.x;
deltaY1 = touchPos.y - object1.transform.position.y;
}
break;
//
case TouchPhase.Moved:
if ((object1Collider == Physics2D.OverlapPoint(touchPos)) && object1ismoveing
&& !object2ismoveing && !object3ismoveing)
object1.transform.position = new Vector2(touchPos.x - deltaX1, touchPos.y - deltaY1);
break;
Comment
Best Answer
Answer by pooryavosoogh · Nov 30, 2020 at 03:26 PM
problem solved !! i thought that it might be something with its collider , and i have just increased the box Collider 2D size and there for it worked and follows my finger position on screen even if i move it so fast , :D