SHARE
TWEET

Untitled

a guest Jun 19th, 2019 55 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public float  translation ;
  2. public float highspeed;//highest speed of the camera
  3. public float incfactor;//increasing ,multiplying number
  4. float timer=0f ;
  5.  public bool ismoving = false;
  6.  
  7.  
  8. Rigidbody2D dia;
  9.  
  10. void Start()
  11. {
  12.  
  13.     dia = GetComponent<Rigidbody2D> ();
  14. }
  15.  
  16.  
  17. void  Update()
  18. {
  19.  
  20.     if (Input.GetMouseButtonDown(0)) {
  21.         RaycastHit2D hit = Physics2D.Raycast(Camera.main.ScreenToWorldPoint(Input.mousePosition), Vector2.zero);
  22.         if(hit.collider != null) {
  23.  
  24.             if (hit.collider.tag =="dialogue") {
  25.                 FindObjectOfType<audioManager> ().Play ("levelbeginclick");
  26.                 Destroy (hit.collider.gameObject);
  27.                 ismoving = true;
  28.             }
  29.             }
  30.         }
  31.  
  32.     if (ismoving == true) {
  33.         Updatemove ();
  34.     }
  35.     }
  36.  
  37.  
  38.  
  39.  
  40.  
  41.  public void Updatemove ()
  42. {
  43.  
  44.     timer += Time.deltaTime;
  45.  
  46.  
  47.  
  48.     if (timer > 1f&& translation<highspeed) {
  49.             timer = 0; // reset timer
  50.         translation +=incfactor ;
  51.         }
  52.  
  53.     transform.Translate (0, translation*Time.deltaTime, 0);
  54.  
  55.  
  56.  
  57.  
  58. }
  59.  
  60. public void stopmoving()
  61. {
  62.     ismoving = false;
  63. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top