Question by 
               kyriakosstavrou · Nov 18, 2016 at 07:28 PM · 
                buttonpositionobject  
              
 
              button change object position
I am beginner and i am trying to make a game... when i click on a ball then change position. i did these is working but when i click on the background the ball change position... can you help me pls?i want just click on the ball to change not on the background... i did this.... what is wrong ?
   if (Input.GetMouseButtonDown (0) & timer > 0) {
                         int rn = Random.Range (0, positions.Length);
                         transform.position = positions [rn];
                         timer = 0.9f;
                         score=score+1;
                         scoretext.text=score.ToString();
                     }  
                 }while(timer > 12);
 
 
              
               Comment
              
 
               
              Add a collider/collider2D to the ball if one does not already exist. Then do something like the following (use On$$anonymous$$ouseDown2D if 2D game) - and remove the code you had u=in the Update function shown above
 void On$$anonymous$$ouseDown ()
 {
     if (timer > 0)
     {
         int rn = Random.Range (0, positions.Length);
         transform.position = positions [rn];
         timer = 0.9f;
         score = score+1;
         scoretext.text = score.ToString();
     }  
 }
 
                 Your answer