Question by 
               darknessfell · Jan 14, 2018 at 02:49 AM · 
                camerascripting problemcamera-movement  
              
 
              Camera movement problem
I'm trying to make a Tower Defense game and I made the camera to move whenever I hover over the edge of the screen but the problem is somehow the camera doesn't detect the edges of the game tab and here's a video showing how it happens:
https://www.dropbox.com/s/k1w2hbtdc0os5wc/2018-01-13%2001-53-09.flv?dl=0
and here's the script:
 private bool doMovement = true;
 
     public float panSpeed = 30f;
     public float panBorderThickness = 10f;
 
     public float scrollSpeed = 5f;
     public float minY = 10f;
     public float maxY = 80f;
 
     // Update is called once per frame
     void Update () {
         if (GameManager.GameIsOver)
         {
             this.enabled = false;
             return;
         }
         if (Input.GetKeyDown(KeyCode.Escape))
             doMovement = !doMovement;
 
         if (!doMovement)
             return;
 
         if (Input.GetKey("w") /*|| Input.mousePosition.y >= Screen.height - panBorderThickness*/) 
         {
             transform.Translate(Vector3.right * panSpeed * Time.deltaTime, Space.World);
         }
 
         if (Input.GetKey("s") /*|| Input.mousePosition.y <= Screen.height - panBorderThickness*/)
         {
             transform.Translate(Vector3.left * panSpeed * Time.deltaTime, Space.World);
         }
 
         if (Input.GetKey("d") /*|| Input.mousePosition.x >= Screen.width - panBorderThickness*/)
         {
             transform.Translate(Vector3.back * panSpeed * Time.deltaTime, Space.World);
         }
 
         if (Input.GetKey("a") /*|| Input.mousePosition.x <= Screen.width - panBorderThickness*/)
         {
             transform.Translate(Vector3.forward * panSpeed * Time.deltaTime, Space.World);
         }
 
         float scroll = Input.GetAxis("Mouse ScrollWheel");
 
         Vector3 pos = transform.position;
         pos.y -= scroll * 1000 * scrollSpeed * Time.deltaTime;
         pos.y = Mathf.Clamp(pos.y, minY, maxY);
 
         transform.position = pos;
     }
I temporarily disabled the edge hovering code so please tell me I did wrong to have the camera move like that
 
                 
                ezgifcom-video-to-gif-3.gif 
                (446.9 kB) 
               
 
              
               Comment
              
 
               
              Your answer
 
 
              koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                