Browse Source

CHANGED:

> PlayerSound script (requires ground recognition)
master
Simon Tran 8 years ago
parent
commit
c1b17b61c5
4 changed files with 64 additions and 9 deletions
  1. +54
    -8
      unity_Project/Assets/Scripts/PlayerSounds.cs
  2. +9
    -0
      unity_Project/Assets/Textures.meta
  3. BIN
      unity_Project/ProjectSettings/ProjectSettings.asset
  4. +1
    -1
      unity_Project/ProjectSettings/ProjectVersion.txt

+ 54
- 8
unity_Project/Assets/Scripts/PlayerSounds.cs View File

@ -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<AudioSource> ();
}
@ -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<CapsuleCollider>;
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:
}

+ 9
- 0
unity_Project/Assets/Textures.meta View File

@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 97def69cc8aa8f0458d67929f23873dd
folderAsset: yes
timeCreated: 1444371283
licenseType: Free
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

BIN
unity_Project/ProjectSettings/ProjectSettings.asset View File


+ 1
- 1
unity_Project/ProjectSettings/ProjectVersion.txt View File

@ -1,2 +1,2 @@
m_EditorVersion: 5.1.2f1
m_EditorVersion: 5.1.3f1
m_StandardAssetsVersion: 0

Loading…
Cancel
Save