Advertisement
Guest User

Untitled

a guest
Oct 30th, 2014
899
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.80 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3.  
  4. public class DistanceScript : MonoBehaviour {
  5.  
  6.  
  7. // I use four different events, defining them here
  8. //FMOD.Studio.EventInstance BattleSound;
  9. FMOD.Studio.EventInstance ForestSound;
  10. //FMOD.Studio.EventInstance WaterSound;
  11. //FMOD.Studio.EventInstance WindSound;
  12.  
  13. // give your FMOD event's parameter a usable name
  14. FMOD.Studio.ParameterInstance volumeDistance;
  15. //FMOD.Studio.ParameterInstance tensionDrums;
  16. //FMOD.Studio.ParameterInstance waterReverb;
  17. //FMOD.Studio.ParameterInstance windChorus;
  18.  
  19. // name the objects with which you want the FPC to interact
  20. GameObject ForestCylinder;
  21. //GameObject BattleCylinder;
  22. //GameObject WindCylinder;
  23. //GameObject WaterCylinder;
  24.  
  25. void Start()
  26. {
  27. //Setting up my ForestSound Event
  28. ForestSound = FMOD_StudioSystem.instance.GetEvent ("event:/ForestSound");
  29. ForestSound.getParameter ("Distance", out volumeDistance);
  30. volumeDistance.setValue (0.0f);
  31.  
  32. //Setting up my BattleSound Event
  33. //BattleSound = FMOD_StudioSystem.instance.GetEvent ("event:/BattleSound");
  34. //BattleSound.getParameter ("increasingDrums", out tensionDrums);
  35. //volumeDistance.setValue (0.0f);
  36.  
  37. // Safety net, make sure that unity can actually find the objects which you defined above
  38. ForestCylinder = GameObject.Find ("ForestCylinder");
  39. //WaterCylinder = GameObject.Find ("WaterCylinder");
  40. //WindCylinder = GameObject.Find ("WindCylinder");
  41. //BattleCylinder = GameObject.Find ("BattleCylinder");
  42. }
  43.  
  44. void Update()
  45. {
  46. float distance = Vector3.Distance (this.gameObject.transform.position, ForestCylinder.transform.position);
  47. float divideddistance = 1 - Mathf.Clamp (distance / 20.0f, 0, 1);
  48. volumeDistance.setValue (divideddistance);
  49. Debug.Log (divideddistance);
  50. }
  51.  
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement