Example #1
0
 public void Shoot()
 {
     bulletClone          = Instantiate(explosiveBullet, spawnPoint.transform.position, spawnPoint.transform.rotation);
     bulletClone.velocity = bulletClone.transform.TransformDirection(Vector3.forward * gunPower * Time.deltaTime);
     sparks.Play();
     sound.PlaySoundEffect();
 }
Example #2
0
 void FireShot()
 {
     if (gunLoaded)
     {
         gunLoaded       = false;
         bullet          = Instantiate(prefabBullet, spawnPoint.transform.position, spawnPoint.transform.rotation);
         bullet.velocity = bullet.transform.TransformDirection(Vector3.forward * gunPower * Time.deltaTime);
         sparks.Play();
         sound.PlaySoundEffect();
     }
 }
 private IEnumerator Shoot()
 {
     while (true)
     {
         if (Input.GetKey(KeyCode.Space))
         {
             bullet          = Instantiate(prefabBullet, spawnPoint.transform.position, spawnPoint.transform.rotation);
             bullet.velocity = bullet.transform.TransformDirection(Vector3.forward * bulletPower * Time.deltaTime);
             sparks.Play();
             sound.PlaySoundEffect();
         }
         yield return(new WaitForSeconds(bulletDelay));
     }
 }
Example #4
0
 void Update()
 {
     if (timeSinceLastBeam > timeBetweenBeams)
     {
         if (Input.GetKey(KeyCode.Space))
         {
             beam.Shoot();
             sound.PlaySoundEffect();
             timeSinceLastBeam = 0f;
         }
     }
     else
     {
         timeSinceLastBeam += Time.deltaTime;
     }
 }