|
|
@ -0,0 +1,63 @@ |
|
|
|
using UnityEngine; |
|
|
|
using System.Collections; |
|
|
|
|
|
|
|
public class PlayerSounds : MonoBehaviour { |
|
|
|
|
|
|
|
private AudioSource source; |
|
|
|
private float volLowRange = 0.5f; // Volume Low Range
|
|
|
|
private float volHighRange = 1.0f; // Volume High Range
|
|
|
|
private float pitchLowRange = 0.90f; // Pitch Low Range
|
|
|
|
private float pitchHighRange = 1.5f; // Pitch High Range
|
|
|
|
private float pitchDefault = 1.0f; // Pitch Default Value
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// AUDIO CLIPS
|
|
|
|
// All sound effects are listed here.
|
|
|
|
public AudioClip sfxFootstep; |
|
|
|
public AudioClip sfxFootstepTEST; |
|
|
|
public AudioClip sfxSwitch; |
|
|
|
public AudioClip sfxRotate; |
|
|
|
|
|
|
|
|
|
|
|
// FUNCTION: Find Audio Source component (attached to Player Avatar Object)
|
|
|
|
void Awake(){ |
|
|
|
source = GetComponent<AudioSource> (); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// FUNCTIONS: Play Sound Effects (SFX)
|
|
|
|
// NOTE: Must add the events to the relevant keyframe within animation clips.
|
|
|
|
|
|
|
|
void PlayFootstep(){ |
|
|
|
float volRandom = Random.Range (volLowRange, volHighRange); |
|
|
|
|
|
|
|
source.pitch = Random.Range (pitchLowRange, pitchHighRange); |
|
|
|
source.PlayOneShot (sfxFootstep,volRandom); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void PlayFootstepTEST(){ |
|
|
|
float volRandom = Random.Range (volLowRange, volHighRange); |
|
|
|
|
|
|
|
source.pitch = Random.Range (pitchLowRange, pitchHighRange); |
|
|
|
source.PlayOneShot (sfxFootstepTEST,volRandom); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void PlaySwitch(){ |
|
|
|
source.pitch = pitchDefault; |
|
|
|
source.PlayOneShot (sfxSwitch,0.7f); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void PlayRotate(){ |
|
|
|
source.pitch = pitchDefault; |
|
|
|
source.PlayOneShot (sfxRotate); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// END BRACKET BELLOW:
|
|
|
|
} |