Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using System.Collections;
- public class DistanceScript : MonoBehaviour {
- // I use four different events, defining them here
- //FMOD.Studio.EventInstance BattleSound;
- FMOD.Studio.EventInstance ForestSound;
- //FMOD.Studio.EventInstance WaterSound;
- //FMOD.Studio.EventInstance WindSound;
- // give your FMOD event's parameter a usable name
- FMOD.Studio.ParameterInstance volumeDistance;
- //FMOD.Studio.ParameterInstance tensionDrums;
- //FMOD.Studio.ParameterInstance waterReverb;
- //FMOD.Studio.ParameterInstance windChorus;
- // name the objects with which you want the FPC to interact
- GameObject ForestCylinder;
- //GameObject BattleCylinder;
- //GameObject WindCylinder;
- //GameObject WaterCylinder;
- void Start()
- {
- //Setting up my ForestSound Event
- ForestSound = FMOD_StudioSystem.instance.GetEvent ("event:/ForestSound");
- ForestSound.getParameter ("Distance", out volumeDistance);
- volumeDistance.setValue (0.0f);
- //Setting up my BattleSound Event
- //BattleSound = FMOD_StudioSystem.instance.GetEvent ("event:/BattleSound");
- //BattleSound.getParameter ("increasingDrums", out tensionDrums);
- //volumeDistance.setValue (0.0f);
- // Safety net, make sure that unity can actually find the objects which you defined above
- ForestCylinder = GameObject.Find ("ForestCylinder");
- //WaterCylinder = GameObject.Find ("WaterCylinder");
- //WindCylinder = GameObject.Find ("WindCylinder");
- //BattleCylinder = GameObject.Find ("BattleCylinder");
- }
- void Update()
- {
- float distance = Vector3.Distance (this.gameObject.transform.position, ForestCylinder.transform.position);
- float divideddistance = 1 - Mathf.Clamp (distance / 20.0f, 0, 1);
- volumeDistance.setValue (divideddistance);
- Debug.Log (divideddistance);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement