|
|
@ -3,9 +3,10 @@ using System.Collections; |
|
|
|
|
|
|
|
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 bool FootOnSand = true; |
|
|
|
public bool FootOnSand = true; |
|
|
|
|
|
|
|
private AudioSource source; |
|
|
|
private float volLowRange = 0.5f; // Volume Low Range
|
|
|
@ -32,6 +33,10 @@ public class PlayerSounds : MonoBehaviour { |
|
|
|
source = GetComponent<AudioSource> (); |
|
|
|
} |
|
|
|
|
|
|
|
void Start(){ |
|
|
|
playerController = PlayerObject.GetComponent<thirdPersonController> (); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// FUNCTIONS: Play Sound Effects (SFX)
|
|
|
|
// NOTE: Must add the events to the relevant keyframe within animation clips.
|
|
|
@ -50,17 +55,12 @@ public class PlayerSounds : MonoBehaviour { |
|
|
|
void CheckGround(){ |
|
|
|
|
|
|
|
//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; |
|
|
|
}else{ |
|
|
|
else |
|
|
|
FootOnSand = false; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|