Advertisement
NPSF3000

Move till clicked

Jun 5th, 2011
302
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var clicksToStop :int = 2;
  2. var delay : float = 0.5;
  3.  
  4. private var clicks = 0;
  5.  
  6. function Start()
  7. {
  8.   MoveUntilClicked();
  9. }
  10.  
  11. function MoveUntilClicked()
  12. {
  13.     clicks = 0;
  14.  
  15.     while (clicks < clicksToStop)
  16.     {
  17.         transform.position = Random.insideUnitCircle*3;
  18.         yield WaitForSeconds(delay);
  19.     }  
  20.  
  21. }
  22.  
  23. function OnMouseDown()
  24. {
  25.     clicks +=1;
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement