Question by 
               Gregorinus · Nov 02, 2016 at 08:38 PM · 
                c#gameobjectparentchildontriggerstay  
              
 
              Moving grabbed object OnTriggerStay2D
Hi everyone! I got problem. I wrote C# script attached to box. I want to let player grab and move it when left CTRL is hold and release when isnt. I got code like below but player grab box and don't want release... Can anyone help me ? I got code like this:
 void OnTriggerStay2D(Collider2D col)
     {
         if (col.gameObject.tag == "Player")
         {
             if (!movingObject)
             {
                 if (Input.GetKey(KeyCode.LeftControl))
                 {
                     this.gameObject.transform.parent = Player.transform;
                     movingObject = true;
                 }
             }
             else if (movingObject)
             {
                 if (!Input.GetKey(KeyCode.LeftControl))
                 {
                     this.gameObject.transform.parent = null;
                     movingObject = false;
                 }
             }
 
         }
     }
 
 
               Comment
              
 
               
              Your answer
 
 
              koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                