Advertisement
lilos404

Move Things

Jul 18th, 2017
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.56 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public class MoveThings : MonoBehaviour {
  6.     private Renderer rn;
  7.     // Use this for initialization
  8.     void Start () {
  9.         rn = GetComponent<Renderer>();
  10.     }
  11.    
  12.     // Update is called once per frame
  13.     void Update () {
  14.        
  15.             var cb = Camera.main.GetOrthographicBounds();
  16.             var bb = rn.bounds;
  17.             if (cb.min.x > (transform.position.x + bb.size.x / 2))
  18.             transform.position = new Vector2(cb.max.x + bb.size.x / 2, transform.position.y);
  19.     }
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement