title: Camera not displaying anything when clamped used to set restrictions in Unity
body: <p>Good day</p>
  
  <p>I am trying to restrict my camera movement using a function that I am using to restrict other elements in a 2D game. When I call this function using my camera, it does something strange.</p>
  
  <p>For some reason it does not display anything as soon as I called the function. I have tested the camera's position using Debug.log, and it seems to be in exactly the same place. The constraints also seem to work, but that is useless if nothing displays. </p>
  
  <p>I am using a Mathf.Clamp function to try and constrain the map. I know that there are many tutorials showing how to constrain map movement, and honestly my approach seems similar. </p>
  
  <p>I want to know why this function is failing. I am trying to keep things generic, and am already using this function to restrict the movement of other game elements.</p>
  
  <p>My code looks like this:</p>
  
  <pre><code>    int cameraSpeed = 10;  
      GameObject camera;
      int maxX = 20;
      int minX = -20;
      int maxY = 20;
      int minY = -20;
  
      // Use this for initialization
      public void constrain(GameObject obj)
      {
          Vector2 pos = obj.transform.position;
          pos.x = Mathf.Clamp(pos.x, -maxX, maxX);
          pos.y = Mathf.Clamp(pos.y, -maxY, maxY);
          obj.transform.position = pos;
      }
  
      void Start () {
          camera = GameObject.Find("Main Camera");
      }
  
      // Update is called once per frame
      void Update()
      {
          if (Input.GetKey(KeyCode.RightArrow))
          {
              camera.transform.Translate(new Vector2(cameraSpeed * Time.deltaTime, 0));
          }
          if (Input.GetKey(KeyCode.LeftArrow))
          {
              camera.transform.Translate(new Vector2(-cameraSpeed * Time.deltaTime, 0));
          }
          if (Input.GetKey(KeyCode.DownArrow))
          {
              camera.transform.Translate(new Vector2(0, -cameraSpeed * Time.deltaTime));
          }
          if (Input.GetKey(KeyCode.UpArrow))
          {
              camera.transform.Translate(new Vector2(0, cameraSpeed * Time.deltaTime));
          }
          Debug.Log(camera.transform.position.x);
          Debug.Log(camera.transform.position.y);
          constrain(camera);
      }
  </code></pre>
  
  <p>Screenshot of game without constraints:
  <a href="https://i.stack.imgur.com/3ZsZH.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/3ZsZH.jpg" alt="enter image description here"></a></p>
  
  <p>Screenshot of game with constraints:
  <a href="https://i.stack.imgur.com/DTiyt.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/DTiyt.jpg" alt="enter image description here"></a></p>
  
  <p>I am new to Unity and am trying to understand it thoroughly. Any advice would be greatly appropriated.</p>