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.
 
 
 
 

51 lines
1.0 KiB

using UnityEngine;
using System.Collections;
public class impactSFX_crate : MonoBehaviour {
private AudioSource source;
public AudioClip sfxImpCrate;
private float volLowRange = 0.5f; // Volume Low Range
private float volHighRange = 1.0f; // Volume High Range
private float pitchLowRange = 0.75f; // Pitch Low Range
private float pitchHighRange = 1.0f; // Pitch High Range
private float pitchDefault = 1.0f; // Pitch Default Value
private float lastHitTime = 0.0f;
private float waitTime = 0.5f;
// FUNCTION: Find Audio Source component (attached to Player Avatar Object)
void Awake(){
source = GetComponent<AudioSource> ();
}
void PlayImpCrate(){
if (Time.time > lastHitTime + waitTime) {
lastHitTime = Time.time;
source.pitch = Random.Range (pitchLowRange, pitchHighRange);
source.PlayOneShot (sfxImpCrate, 0.85f);
}
}
void OnCollisionEnter(Collision col){
PlayImpCrate ();
}
// // Use this for initialization
// void Start () {
//
// }
//
// // Update is called once per frame
// void Update () {
//
// }
}