Question by 
               astrokiiD · May 09, 2016 at 05:13 PM · 
                spawnspawningspawning problemsdrop  
              
 
              Spawn a box and when i press space drop that box
I try to make a script that spawn my object after i press space. I have a pendul script for my box and i don't know how to make a spawn script. This is what i have but it dosen't work. Any ideeas how to make it work ? public class BoxDrop : MonoBehaviour {
 public GameObject go;
 public GameObject cutie;
 private GameObject clonaCutie;
 private int counter;
 // Use this for initialization
 void Start () {
     counter = 0;
 }
 
 // Update is called once per frame
 void Update () {
     if (Input.GetKeyUp("up"))
     {
         if(counter == 0)
         {
             counter = 1;
             Destroy(go.GetComponent<HingeJoint2D>());
             go.transform.GetComponent<Rigidbody2D>().constraints = RigidbodyConstraints2D.FreezePositionX;
             clonaCutie = (GameObject)Instantiate(go, transform.position, transform.rotation);
         } else
         {
             Destroy(clonaCutie.GetComponent<HingeJoint2D>());
             clonaCutie.transform.GetComponent<Rigidbody2D>().constraints = RigidbodyConstraints2D.FreezePositionX;
             clonaCutie = (GameObject)Instantiate(go, transform.position, transform.rotation);
         }
     }
 }
 
              
               Comment
              
 
               
              Your answer