- using UnityEngine;
- using System.Collections;
-
- public class PlayerSounds : MonoBehaviour {
-
- public GameObject PlayerObject;
-
- 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 sfxFootSand;
- public AudioClip sfxFootFloor;
- public AudioClip sfxTEST;
- public AudioClip sfxSwitch;
- public AudioClip sfxPickUp;
- public AudioClip sfxRotateL;
- public AudioClip sfxRotateR;
- public AudioClip sfxJump;
- public AudioClip sfxLand;
-
- // 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);
- // SAND GROUND
- source.pitch = Random.Range (pitchLowRange, pitchHighRange);
- source.PlayOneShot (sfxFootSand,volRandom);
-
- }
-
-
-
-
-
-
-
- public void PlayTest(){
- float volRandom = Random.Range (volLowRange, volHighRange);
-
- source.pitch = Random.Range (pitchLowRange, pitchHighRange);
- source.PlayOneShot (sfxTEST,volRandom);
- }
-
-
-
- void PlayJump(){
- float volRandom = Random.Range (volLowRange, volHighRange);
- source.PlayOneShot (sfxJump,volRandom);
- }
-
-
- void PlayLand(){
- float volRandom = Random.Range (volLowRange, volHighRange);
- source.PlayOneShot (sfxLand,volRandom);
- }
-
-
- public void PlaySwitch(){
- source.pitch = pitchDefault;
- source.PlayOneShot (sfxSwitch,0.7f);
- }
-
-
-
- public void PlayPickUp(){
- source.pitch = pitchDefault;
- source.PlayOneShot (sfxPickUp,0.7f);
- }
-
-
- public void PlayRotateL(){
- source.pitch = pitchDefault;
- source.PlayOneShot (sfxRotateL);
- }
-
-
- public void PlayRotateR(){
- source.pitch = pitchDefault;
- source.PlayOneShot (sfxRotateR);
- }
-
-
-
-
- // END BRACKET BELLOW:
- }
|