Esempio n. 1
0
 // Update is called once per frame
 void Update()
 {
     //This if statement is saying if the Space Key is being pressed down, bullets will fire from the ship
     if (Input.GetKeyDown(KeyCode.Space))
     {
         GameObject InstantiateBullet;
         InstantiateBullet = Instantiate(bulletPrefab, shootPoint.position, shootPoint.rotation);
         InstantiateBullet.GetComponent <Rigidbody2D> ().AddForce(transform.right * BulletSpeed);
     }
 }
Esempio n. 2
0
    // Update is called once per frame
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.Space))
        {
            GameObject InstantiateBullet;

            InstantiateBullet = Instantiate(Lazer1Prefab, this.transform.position + Offset, Quaternion.identity) as GameObject;
            if (this.gameObject.GetComponent <PlayerMovement> ().FlipedRight)
            {
                InstantiateBullet.GetComponent <Bullet> ().force *= 1;
            }
            else
            {
                InstantiateBullet.GetComponent <Bullet> ().force *= -1;
            }
        }
    }