Exemple #1
0
 // Update is called once per frame
 void Update()
 {
     if (Input.GetMouseButtonDown(1) && currentGrenades > 0)
     {
         currentGrenades--;
         //Instantiate the bullet and rotate.
         GameObject TemporaryBullet;
         TemporaryBullet = Instantiate(Grenade, BulletEmitter.transform.position, BulletEmitter.transform.rotation) as GameObject;
         //Get the Rigidbody component from the instantiated Bullet and give the bullet forward momentum.
         Rigidbody TempBody;
         TempBody = TemporaryBullet.GetComponent <Rigidbody>();
         TempBody.AddForce(transform.forward * BulletForce);
     }
 }
Exemple #2
0
 public void BulletInstantiate(Collider obj)
 {
     if (!loaded)
     {
         Timer = 0;
         if (gameObject.transform.childCount < 4)
         {
             GameObject TemporaryBullet;
             TemporaryBullet = Instantiate(bullet, obj.GetComponent <shooting>().bulletEmitter.transform.position, obj.GetComponent <shooting>().bulletEmitter.transform.rotation) as GameObject;
             TemporaryBullet.GetComponent <Bullet>().collisionEnable = false;
             TemporaryBullet.transform.Rotate(Vector3.left * 90);
             TemporaryBullet.transform.parent = obj.GetComponent <shooting>().transform;
             TemporaryBullet.GetComponent <Rigidbody>().useGravity       = false;
             TemporaryBullet.GetComponent <Rigidbody>().detectCollisions = false;
         }
     }
 }
 // Update is called once per frame
 void Update()
 {
     if (Input.GetKeyDown("f"))
     {
         if (mineCount <= 0)
         {
             return;
         }
         mineCount--;
         //Instantiate the Mine and rotate.
         GameObject TemporaryBullet;
         TemporaryBullet = Instantiate(Mines, BulletEmitter.transform.position, BulletEmitter.transform.rotation) as GameObject;
         //Get the Rigidbody component from the instantiated Mine and give the bullet Mine momentum.
         Rigidbody TempBody;
         TempBody = TemporaryBullet.GetComponent <Rigidbody>();
         TempBody.AddForce(transform.forward * BulletForce);
     }
 }