Browse Source

- fixed ground check in play sounds

master
Joshua Reason 9 years ago
parent
commit
44e5aa686c
5 changed files with 14 additions and 21 deletions
  1. BIN
      unity_Project/Assets/Character/Character_Animation.controller
  2. +11
    -11
      unity_Project/Assets/Scripts/PlayerSounds.cs
  3. +3
    -1
      unity_Project/Assets/Scripts/thirdPersonController.cs
  4. +0
    -9
      unity_Project/Assets/Textures.meta
  5. BIN
      unity_Project/Assets/_Scenes/MainLevel.unity

BIN
unity_Project/Assets/Character/Character_Animation.controller View File


+ 11
- 11
unity_Project/Assets/Scripts/PlayerSounds.cs View File

@ -3,9 +3,10 @@ using System.Collections;
public class PlayerSounds : MonoBehaviour { public class PlayerSounds : MonoBehaviour {
public GameObject PlayerObject; //Player1 or Player2 object. Assign object component in inspector.
public GameObject PlayerObject;
private thirdPersonController playerController;//Player1 or Player2 object. Assign object component in inspector.
//private Collider playerCollider; //private Collider playerCollider;
private bool FootOnSand = true;
public 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
@ -32,6 +33,10 @@ public class PlayerSounds : MonoBehaviour {
source = GetComponent<AudioSource> (); source = GetComponent<AudioSource> ();
} }
void Start(){
playerController = PlayerObject.GetComponent<thirdPersonController> ();
}
// 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.
@ -50,17 +55,12 @@ public class PlayerSounds : MonoBehaviour {
void CheckGround(){ void CheckGround(){
//playerCollider = PlayerObject.GetComponent<CapsuleCollider>; //playerCollider = PlayerObject.GetComponent<CapsuleCollider>;
RaycastHit FootHit;
Ray ray = new Ray(transform.position, -Vector3.up);
if (Physics.Raycast (ray, out FootHit, 1.3f)) {
if (FootHit.transform.tag == "sand")
Debug.Log ("groundCheck");
RaycastHit FootHit = playerController.hit;
if (FootHit.transform.tag == "sand")
FootOnSand = true; FootOnSand = true;
}else{
else
FootOnSand = false; FootOnSand = false;
}
} }

+ 3
- 1
unity_Project/Assets/Scripts/thirdPersonController.cs View File

@ -42,6 +42,8 @@ public class thirdPersonController : MonoBehaviour {
public Collider curCollider; public Collider curCollider;
public RaycastHit hit;
@ -58,7 +60,7 @@ public class thirdPersonController : MonoBehaviour {
void FixedUpdate(){ void FixedUpdate(){
RaycastHit hit;
//RaycastHit hit;
Ray ray = new Ray(transform.position, -Vector3.up); Ray ray = new Ray(transform.position, -Vector3.up);

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

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

BIN
unity_Project/Assets/_Scenes/MainLevel.unity View File


Loading…
Cancel
Save