Question by 
               Trex1332 · Nov 22, 2020 at 06:38 PM · 
                2d game2d-physics2d-gameplay  
              
 
              when i Drag the Block the 2d Collider Doesn't Follow it.
im making a mobile game and when i move the object the Collider doesn't move with it so it stay in the same place? what have a i done wrong?
         if(Input.touchCount > 0)
         {
             Touch touch = Input.GetTouch(0);
             Vector2 touchPosition = Camera.main.ScreenToWorldPoint(touch.position);
 
             if (touch.phase == TouchPhase.Began)
             {
                 Collider2D touchedCollider = Physics2D.OverlapPoint(touchPosition);
                 if(col == touchedCollider)
                 {
                     moveAllowed = true;
                     //rigidbod.gravityScale = 0 ;
                 }
             }
             if(touch.phase == TouchPhase.Moved)
             {
                 if (moveAllowed)
                 {
                     transform.position = new Vector2(touchPosition.x, touchPosition.y);
                 }
             }
             if (touch.phase == TouchPhase.Ended)
             {
                 moveAllowed = false;
                 //rigidbod.gravityScale = 1;
             }
         }
 
               
                 
                pci.png 
                (158.3 kB) 
               
 
              
               Comment
              
 
               
              Your answer
 
             Follow this Question
Related Questions
Help 2D Custom HillClimbRacingGame 0 Answers
how do I make 2 player sprites not interact? 0 Answers
Player Not Moving With Platform 2D 1 Answer
How to create a 2D obstacle as a question 0 Answers
2D character falls through floor 1 Answer