Question by 
               Darkcape101 · Sep 01, 2015 at 08:44 PM · 
                scripting problemscript.script error  
              
 
              My gameobject keeps leaving the screen
i dont really know what is going on with my code, i dont get errors or anything and yet the gameobject keeps going out of bounds even though i set ymin and ymax. the game is similiar to pong and i am trying to make the player not leave the screen. the game is 2d so i opted out of using z and i didnt really need to clamp the x values because the player does not have the option to move on the x axis
 public float yMin, yMax;
     void Update () 
     {
         if (Input.GetKey (KeyCode.W)) {
             transform.Translate (Vector3.up * Time.deltaTime * 10);
         }
         if (Input.GetKey (KeyCode.S)) {
             transform.Translate (Vector3.down * Time.deltaTime * 10);
 
         }
         Vector3 temp = GetComponent<Rigidbody> ().position;
         temp.y = Mathf.Clamp (GetComponent<Rigidbody> ().position.y, yMin, yMax);
     }
               Comment
              
 
               
              Your answer
 
 
              koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                