using UnityEngine;
|
|
using System.Collections;
|
|
|
|
public class impactSFX_beam : MonoBehaviour {
|
|
|
|
private AudioSource source;
|
|
public AudioClip sfxImpBeam;
|
|
|
|
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 PlayImpBeam(){
|
|
if (Time.time > lastHitTime + waitTime) {
|
|
lastHitTime = Time.time;
|
|
source.pitch = Random.Range (pitchLowRange, pitchHighRange);
|
|
source.PlayOneShot (sfxImpBeam, 0.85f);
|
|
}
|
|
}
|
|
|
|
|
|
void OnCollisionEnter(Collision col){
|
|
PlayImpBeam ();
|
|
|
|
}
|
|
|
|
|
|
// // Use this for initialization
|
|
// void Start () {
|
|
//
|
|
// }
|
|
//
|
|
// // Update is called once per frame
|
|
// void Update () {
|
|
//
|
|
// }
|
|
|
|
|
|
|
|
}
|