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(); }
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)); } }
void Update() { if (timeSinceLastBeam > timeBetweenBeams) { if (Input.GetKey(KeyCode.Space)) { beam.Shoot(); sound.PlaySoundEffect(); timeSinceLastBeam = 0f; } } else { timeSinceLastBeam += Time.deltaTime; } }