|
@ -3,7 +3,9 @@ using System.Collections; |
|
|
|
|
|
|
|
|
public class PlayerSounds : MonoBehaviour { |
|
|
public class PlayerSounds : MonoBehaviour { |
|
|
|
|
|
|
|
|
public GameObject PlayerObject; |
|
|
|
|
|
|
|
|
public GameObject PlayerObject; //Player1 or Player2 object. Assign object component in inspector.
|
|
|
|
|
|
//private Collider playerCollider;
|
|
|
|
|
|
private bool FootOnSand = true; |
|
|
|
|
|
|
|
|
private AudioSource source; |
|
|
private AudioSource source; |
|
|
private float volLowRange = 0.5f; // Volume Low Range
|
|
|
private float volLowRange = 0.5f; // Volume Low Range
|
|
@ -14,7 +16,7 @@ public class PlayerSounds : MonoBehaviour { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// AUDIO CLIPS
|
|
|
// AUDIO CLIPS
|
|
|
// All sound effects are listed here.
|
|
|
|
|
|
|
|
|
// All player sound effects are listed here.
|
|
|
public AudioClip sfxFootSand; |
|
|
public AudioClip sfxFootSand; |
|
|
public AudioClip sfxFootFloor; |
|
|
public AudioClip sfxFootFloor; |
|
|
public AudioClip sfxTEST; |
|
|
public AudioClip sfxTEST; |
|
@ -25,7 +27,7 @@ public class PlayerSounds : MonoBehaviour { |
|
|
public AudioClip sfxJump; |
|
|
public AudioClip sfxJump; |
|
|
public AudioClip sfxLand; |
|
|
public AudioClip sfxLand; |
|
|
|
|
|
|
|
|
// FUNCTION: Find Audio Source component (attached to Player Avatar Object)
|
|
|
|
|
|
|
|
|
// FUNCTION: Find Audio Source component (attached to **Player Avatar** Object)
|
|
|
void Awake(){ |
|
|
void Awake(){ |
|
|
source = GetComponent<AudioSource> (); |
|
|
source = GetComponent<AudioSource> (); |
|
|
} |
|
|
} |
|
@ -34,19 +36,56 @@ public class PlayerSounds : MonoBehaviour { |
|
|
// FUNCTIONS: Play Sound Effects (SFX)
|
|
|
// FUNCTIONS: Play Sound Effects (SFX)
|
|
|
// NOTE: Must add the events to the relevant keyframe within animation clips.
|
|
|
// NOTE: Must add the events to the relevant keyframe within animation clips.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void Update () { |
|
|
|
|
|
//CheckGround ();
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// GROUND-TYPE RECOGNITION
|
|
|
|
|
|
// > Needs proper logic
|
|
|
|
|
|
// > Purpose of this function is to determine whether the player object is
|
|
|
|
|
|
// standing on the terrain object that has been tagged with "sand".
|
|
|
|
|
|
void CheckGround(ControllerColliderHit FootHit){ |
|
|
|
|
|
|
|
|
|
|
|
//playerCollider = PlayerObject.GetComponent<CapsuleCollider>;
|
|
|
|
|
|
|
|
|
|
|
|
if (FootHit.gameObject.tag == "sand") { |
|
|
|
|
|
FootOnSand = true; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
else { |
|
|
|
|
|
FootOnSand = false; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void PlayFootstep(){ |
|
|
void PlayFootstep(){ |
|
|
float volRandom = Random.Range (volLowRange, volHighRange); |
|
|
float volRandom = Random.Range (volLowRange, volHighRange); |
|
|
// SAND GROUND
|
|
|
|
|
|
source.pitch = Random.Range (pitchLowRange, pitchHighRange); |
|
|
|
|
|
source.PlayOneShot (sfxFootSand,volRandom); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// SAND FOOTSTEP SOUND
|
|
|
|
|
|
if(FootOnSand == true){ |
|
|
|
|
|
// SAND GROUND
|
|
|
|
|
|
source.pitch = Random.Range (pitchLowRange, pitchHighRange); |
|
|
|
|
|
source.PlayOneShot (sfxFootSand,volRandom); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// GENERAL FOOTSTEP SOUND
|
|
|
|
|
|
else if (FootOnSand == false){ |
|
|
|
|
|
source.pitch = Random.Range (pitchLowRange, pitchHighRange); |
|
|
|
|
|
source.PlayOneShot (sfxFootFloor,volRandom); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void PlayTest(){ |
|
|
public void PlayTest(){ |
|
|
float volRandom = Random.Range (volLowRange, volHighRange); |
|
|
float volRandom = Random.Range (volLowRange, volHighRange); |
|
@ -69,6 +108,13 @@ public class PlayerSounds : MonoBehaviour { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//CROSS-SCRIPT SOUNDS
|
|
|
|
|
|
// Sound functions assigned in different scripts, specifically those that
|
|
|
|
|
|
// require controller button presses.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void PlaySwitch(){ |
|
|
public void PlaySwitch(){ |
|
|
source.pitch = pitchDefault; |
|
|
source.pitch = pitchDefault; |
|
|
source.PlayOneShot (sfxSwitch,0.7f); |
|
|
source.PlayOneShot (sfxSwitch,0.7f); |
|
@ -96,5 +142,5 @@ public class PlayerSounds : MonoBehaviour { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// END BRACKET BELLOW:
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
} |