diff --git a/unity_Project/Assets/Scripts/PlayerSounds.cs b/unity_Project/Assets/Scripts/PlayerSounds.cs index 10a0a03..3c3a142 100644 --- a/unity_Project/Assets/Scripts/PlayerSounds.cs +++ b/unity_Project/Assets/Scripts/PlayerSounds.cs @@ -3,7 +3,9 @@ using System.Collections; 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 float volLowRange = 0.5f; // Volume Low Range @@ -14,7 +16,7 @@ public class PlayerSounds : MonoBehaviour { // AUDIO CLIPS - // All sound effects are listed here. + // All player sound effects are listed here. public AudioClip sfxFootSand; public AudioClip sfxFootFloor; public AudioClip sfxTEST; @@ -25,7 +27,7 @@ public class PlayerSounds : MonoBehaviour { public AudioClip sfxJump; 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(){ source = GetComponent (); } @@ -34,19 +36,56 @@ public class PlayerSounds : MonoBehaviour { // FUNCTIONS: Play Sound Effects (SFX) // 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; + + if (FootHit.gameObject.tag == "sand") { + FootOnSand = true; + } + + + else { + FootOnSand = false; + } + + } + + + void PlayFootstep(){ 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(){ 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(){ source.pitch = pitchDefault; source.PlayOneShot (sfxSwitch,0.7f); @@ -96,5 +142,5 @@ public class PlayerSounds : MonoBehaviour { - // END BRACKET BELLOW: + } diff --git a/unity_Project/Assets/Textures.meta b/unity_Project/Assets/Textures.meta new file mode 100644 index 0000000..8915b1d --- /dev/null +++ b/unity_Project/Assets/Textures.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 97def69cc8aa8f0458d67929f23873dd +folderAsset: yes +timeCreated: 1444371283 +licenseType: Free +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/unity_Project/ProjectSettings/ProjectSettings.asset b/unity_Project/ProjectSettings/ProjectSettings.asset index ac67012..6faa7cf 100644 Binary files a/unity_Project/ProjectSettings/ProjectSettings.asset and b/unity_Project/ProjectSettings/ProjectSettings.asset differ diff --git a/unity_Project/ProjectSettings/ProjectVersion.txt b/unity_Project/ProjectSettings/ProjectVersion.txt index 8c353d8..c609863 100644 --- a/unity_Project/ProjectSettings/ProjectVersion.txt +++ b/unity_Project/ProjectSettings/ProjectVersion.txt @@ -1,2 +1,2 @@ -m_EditorVersion: 5.1.2f1 +m_EditorVersion: 5.1.3f1 m_StandardAssetsVersion: 0