You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

46 lines
922 B

  1. using UnityEngine;
  2. using System.Collections;
  3. public class impactSFX_crate : MonoBehaviour {
  4. private AudioSource source;
  5. public AudioClip sfxImpCrate;
  6. private float volLowRange = 0.5f; // Volume Low Range
  7. private float volHighRange = 1.0f; // Volume High Range
  8. private float pitchLowRange = 0.75f; // Pitch Low Range
  9. private float pitchHighRange = 1.0f; // Pitch High Range
  10. private float pitchDefault = 1.0f; // Pitch Default Value
  11. // FUNCTION: Find Audio Source component (attached to Player Avatar Object)
  12. void Awake(){
  13. source = GetComponent<AudioSource> ();
  14. }
  15. void PlayImpCrate(){
  16. source.pitch = Random.Range (pitchLowRange, pitchHighRange);
  17. source.PlayOneShot (sfxImpCrate,0.85f);
  18. }
  19. void OnCollisionEnter(Collision col){
  20. PlayImpCrate ();
  21. }
  22. // // Use this for initialization
  23. // void Start () {
  24. //
  25. // }
  26. //
  27. // // Update is called once per frame
  28. // void Update () {
  29. //
  30. // }
  31. }