// Update is called once per frame void Update() { audioSource = SVUtilities.SetOrAddAudioSource(gameObject); audioSource.clip = houseSound; audioSource.volume = 3f; audioSource.Play(); }
// Update is called once per frame void Update() { if (lever.leverWasSwitched && lever.leverIsOn && leverUp) { if (audioSource == null) { audioSource = SVUtilities.SetOrAddAudioSource(gameObject); } audioSource.clip = leverUp; audioSource.pitch = Random.Range(minPitch, maxPitch); audioSource.volume = volume; audioSource.Play(); } else if (lever.leverWasSwitched && !lever.leverIsOn && leverDown) { if (audioSource == null) { audioSource = SVUtilities.SetOrAddAudioSource(gameObject); } audioSource.clip = leverDown; audioSource.pitch = Random.Range(minPitch, maxPitch); audioSource.volume = volume; audioSource.Play(); } }
// Update is called once per frame void Update() { if (button.buttonPressed && buttonDown) { if (audioSource == null) { audioSource = SVUtilities.SetOrAddAudioSource(gameObject); } audioSource.clip = buttonDown; audioSource.pitch = Random.Range(minPitch, maxPitch); audioSource.volume = volume; audioSource.Play(); } else if (button.buttonUnpressed && buttonUp) { if (audioSource == null) { audioSource = SVUtilities.SetOrAddAudioSource(gameObject); } audioSource.clip = buttonUp; audioSource.pitch = Random.Range(minPitch, maxPitch); audioSource.volume = volume; audioSource.Play(); } }
// Update is called once per frame void Update() { if (grabbable.inHand) { if (audioSource == null) { audioSource = SVUtilities.SetOrAddAudioSource(gameObject); audioSource.clip = sliderClip; audioSource.volume = volume; audioSource.loop = true; } audioSource.pitch = slider.value * (maxPitch - minPitch) + minPitch; if (!audioSource.isPlaying) { audioSource.Play(); } } else { if (audioSource != null && audioSource.isPlaying) { audioSource.Stop(); } } }
private void OnTriggerStay() { if (Input.GetKey(KeyCode.Q) && Time.time >= nextSoundTime) { audioSource = SVUtilities.SetOrAddAudioSource(gameObject); audioSource.clip = soundOnHit; audioSource.pitch = pitchAdjust; audioSource.volume = gain; audioSource.Play(); // write down when we will be finished: nextSoundTime = Time.time + .01f; //Debug.Log(soundOnHit.length); } }
private void OnCollisionEnter(Collision collision) { if (grabbable.inHand && hapticsOnCollision) { input.RumbleActiveController(vibrationLengthInSeconds); if (soundOnHit) { if (audioSource == null) { audioSource = SVUtilities.SetOrAddAudioSource(gameObject); audioSource.clip = soundOnHit; } audioSource.pitch = Random.Range(minPitch, maxPitch); audioSource.volume = volume; audioSource.Play(); } } }
private void OnCollisionEnter(Collision collision) { // can't play if last one not finished: if (Time.time >= nextSoundTime) { audioSource = SVUtilities.SetOrAddAudioSource(gameObject); audioSource.clip = soundOnHit; audioSource.pitch = pitchAdjust; float volume = collision.gameObject.GetComponent <Rigidbody>().velocity.magnitude / 3f + gain; if (volume > 1f) { volume = 1f; } audioSource.volume = volume; audioSource.Play(); // write down when we will be finished: nextSoundTime = Time.time + .15f; //Debug.Log(soundOnHit.length); } }