Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public float translation ;
- public float highspeed;//highest speed of the camera
- public float incfactor;//increasing ,multiplying number
- float timer=0f ;
- public bool ismoving = false;
- Rigidbody2D dia;
- void Start()
- {
- dia = GetComponent<Rigidbody2D> ();
- }
- void Update()
- {
- if (Input.GetMouseButtonDown(0)) {
- RaycastHit2D hit = Physics2D.Raycast(Camera.main.ScreenToWorldPoint(Input.mousePosition), Vector2.zero);
- if(hit.collider != null) {
- if (hit.collider.tag =="dialogue") {
- FindObjectOfType<audioManager> ().Play ("levelbeginclick");
- Destroy (hit.collider.gameObject);
- ismoving = true;
- }
- }
- }
- if (ismoving == true) {
- Updatemove ();
- }
- }
- public void Updatemove ()
- {
- timer += Time.deltaTime;
- if (timer > 1f&& translation<highspeed) {
- timer = 0; // reset timer
- translation +=incfactor ;
- }
- transform.Translate (0, translation*Time.deltaTime, 0);
- }
- public void stopmoving()
- {
- ismoving = false;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement