- Home /
Point Collection Bug
Player has rigidbody2D, circle collider2d and a drag script. Points has box collider2D with trigger and a point script. While I am trying to collect them behind a wall, the player stacks there which is normal but if I move mouse on points even the player is not there, I can collect points. Here is script:

 ///////////////////////////DRAG SCRIPT///////////////////////
 [RequireComponent(typeof(Rigidbody2D))]
 
 public class Drag : MonoBehaviour {
 
     private Vector3 screenPoint;
     private Vector3 offset;
     
     void OnMouseDown() {
         offset = gameObject.transform.position - Camera.main.ScreenToWorldPoint(new Vector3(Input.mousePosition.x, Input.mousePosition.y, screenPoint.z));
     }
     
     void OnMouseDrag()
     {
             Vector3 curScreenPoint = new Vector3 (Input.mousePosition.x, Input.mousePosition.y, screenPoint.z);
             Vector3 curPosition = Camera.main.ScreenToWorldPoint (curScreenPoint) + offset;
             //transform.position = curPosition;
             rigidbody2D.MovePosition(curPosition);
     }
 }
 ////////////////////////////////////////////////////////////////
 
 //////////////////////////COLLECT POINTS///////////////////////
 scoreScript score;
     void OnTriggerEnter2D(Collider2D other)
     {
         if(other.tag == "Player")
         {
             score = GameObject.Find ("Main Camera").GetComponent<scoreScript>();
             score.IncreaseScore (0,1,0);
             Destroy (this.gameObject);
         }
     }
 }
 //////////////////////////////////////////////////////////////
 
                 
                bughappens.png 
                (14.5 kB) 
               
 
              
               Comment
              
 
               
              Your answer
 
 
             Follow this Question
Related Questions
adding drag to a relative force 0 Answers
Character Slowly sliding off platform 1 Answer
A position locked hinge joint with drag and no gravity? 1 Answer
Rigidbody loses speed 1 Answer
Objects with colliders going through walls and each other. 3 Answers
 koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                