Search Unity

When Player Collides With Mesh Collider Enable Reverb

Discussion in 'Scripting' started by JW_moore, Mar 29, 2017.

  1. JW_moore

    JW_moore

    Joined:
    Jul 27, 2016
    Posts:
    10
    I have a gym area in my game and wanted to add reverb to the room. he code i have for the player works but not for the collider.

    Code (JavaScript):
    1. var TheDistance : float = GymDis.DistanceToTarget;
    2.  
    3.  
    4. function Update () {
    5.         if (TheDistance == 1)
    6.         {
    7.             GetComponent.<AudioReverbZone>().enabled = true;
    8.         }
    9.         else if (TheDistance == 0)
    10.         {
    11.             GetComponent.<AudioReverbZone>().enabled = false;
    12.         }
    13. }
    Code (JavaScript):
    1. static var DistanceToTarget : float;
    2.  
    3. var toTarget : float;
    4.  
    5. function OnTriggerEnter (col : MeshCollider) {
    6.      if(col.gameObject.CompareTag("Player"))
    7.      {
    8.      DistanceToTarget = 1;
    9. }
    10. }
    i don't have an exit function yet