// Use this for initialization void Start () { theSound = FMODUnity.RuntimeManager.CreateInstance(soundEvent); // a bunch of default vaiables which trick fmod into looping theSound.setParameterValue("Distance", 0.0f); theSound.setParameterValue("Direction", 0.0f); }
void OnHover(bool status) { if (status) { if (m_Menu) { m_Event.setParameterValue(m_ActionParameter, m_OnHoverParameterValue); StartEvent(); } } }
public void PlaySound() { Vector3 position = this.gameObject.GetComponent <FirstPersonController> ().Position; float distance; m_PlayerSpeed = this.gameObject.rigidbody.velocity.normalized.magnitude; distance = Vector3.Distance(position, m_LastPosition); //Debug.Log ("Distance = " + distance + " -- DistanceBFSound = " + m_DistanceBeforeSound); if (distance > m_DistanceBeforeSound) { m_LastPosition = position; if (m_FirstTime) { m_FirstTime = false; m_Surface = 0.99f; m_Event.setParameterValue(m_Parameter, m_Surface); StartEvent(); } else { switch (GetMaterial()) { case "Wood": m_Surface = 0.05f; m_Event.setParameterValue(m_Parameter, m_Surface); break; case "Carpet": m_Surface = 0.15f; m_Event.setParameterValue(m_Parameter, m_Surface); break; case "Glass": m_Surface = 0.25f; m_Event.setParameterValue(m_Parameter, m_Surface); break; } //Debug.Log ("Time = " + m_Time); if (getPlaybackState() == PLAYBACK_STATE.SUSTAINING && m_Time >= m_WalkingSoundSpeed) { StartEvent(); m_StartTime = Time.time; } } } else { m_LastPosition = position; } }
public void PlaySoundEffect() { if (getPlaybackState() != FMOD.Studio.PLAYBACK_STATE.PLAYING) { m_Started = false; } if (!m_Started) { if (m_Parameters.Length != 0) { m_Event.setParameterValue(m_Parameters[0], m_Value); } StartEvent(); } }
protected void PlayEvent() { if (eventName != null) { if (!eventInstance.isValid()) { eventInstance = FMODUnity.RuntimeManager.CreateInstance(eventName); } // Only attach to object if the game is actually playing, not auditioning. if (Application.isPlaying && TrackTargetObject) { Rigidbody rb = TrackTargetObject.GetComponent <Rigidbody>(); if (rb) { FMODUnity.RuntimeManager.AttachInstanceToGameObject(eventInstance, TrackTargetObject.transform, rb); } else { FMODUnity.RuntimeManager.AttachInstanceToGameObject(eventInstance, TrackTargetObject.transform, TrackTargetObject.GetComponent <Rigidbody2D>()); } } else { eventInstance.set3DAttributes(FMODUnity.RuntimeUtils.To3DAttributes(Vector3.zero)); } foreach (var param in parameters) { eventInstance.setParameterValue(param.Name, param.Value); } eventInstance.start(); } }
IEnumerator TapeStop() { IsStopping = true; FMODUnity.RuntimeManager.PlayOneShot(audioManager.cartridgeStop); float t = 0.0f; float targetT = playing.GetComponent <CartridgeData>().GetDataHolder().fadeOutTimeOnStop; float value; // if we're dividing by zero, skip the lerp and the math error if (targetT != t) { while (t < targetT) { t += Time.deltaTime; value = Mathf.Lerp(1, 0, t / targetT); playingTrack.setParameterValue("TapeStart", value); yield return(null); } } playingTrack.stop(FMOD.Studio.STOP_MODE.IMMEDIATE); IsStopping = false; }
// Update is called once per frame void Update() { if (isAttacking) { slashTimer -= Time.deltaTime; if (slashTimer < 0) { isAttacking = false; slash.SetActive(false); } } inputVector = new Vector2(Input.GetAxis("Horizontal"), Input.GetAxis("Vertical")); if (Input.GetButtonDown("Fire1") && !isAttacking) { animator.SetTrigger("Attack"); inputVector = Vector2.zero; FMODUnity.RuntimeManager.PlayOneShot(PlayerAttack, transform.position); Attack(); } if (!isAttacking) { Vector3 moveVector = transform.position + new Vector3(inputVector.x, inputVector.y) * Time.deltaTime * moveSpeed; rb2D.MovePosition(moveVector); animator.SetFloat("Horizontal", inputVector.x); animator.SetFloat("Vertical", inputVector.y); } walk.setParameterValue("speed", inputVector != Vector2.zero ? 1 : 0); }
private void PlayWeaponSound() { WeaponType type = weaponHolder.GetComponentInChildren <Weapon>().type; if (type == WeaponType.GiantSword) { FMOD.Studio.EventInstance attackSound = FMODUnity.RuntimeManager.CreateInstance("event:/Attack/Sword"); //attackSound.setPitch() weaponHolder.GetComponentInChildren <Weapon>().attackSound = attackSound; attackSound.setParameterValue("Hit", 0); attackSound.start(); } else if (type == WeaponType.LightSword) { FMOD.Studio.EventInstance attackSound = FMODUnity.RuntimeManager.CreateInstance("event:/Attack/StabSword"); //attackSound.setPitch() weaponHolder.GetComponentInChildren <Weapon>().attackSound = attackSound; attackSound.setParameterValue("Hit", 0); attackSound.start(); } else { FMOD.Studio.EventInstance attackSound = FMODUnity.RuntimeManager.CreateInstance("event:/Attack/Hammer"); //attackSound.setPitch() weaponHolder.GetComponentInChildren <Weapon>().attackSound = attackSound; attackSound.setParameterValue("Hit", 0); attackSound.start(); } }
// Update is called once per frame void FixedUpdate() { if (Random.Range(0, 1000) <= diceCheck) { Rand = Random.Range(0, 100); SendRandomChangeToFMOD(); } musicEv.setParameterValue("Profondeur", t.getProfondeur()); ventEv.setParameterValue("Profondeur", t.getProfondeur()); if (p.deadByOxygen) { musicEv.stop(FMOD.Studio.STOP_MODE.IMMEDIATE); } }
// Update is called once per frame protected virtual void Update() { var scale = player.transform.localScale; scale.y = -Mathf.Sign(Physics2D.gravity.y); player.transform.localScale = scale; var x = Input.GetAxis("Horizontal"); var velocity = player.velocity; velocity.x = speed * x; player.GetComponent <Animator>().SetBool("Running", !Mathf.Approximately(velocity.x, 0f)); var isTouching = player.IsTouching(filter); if (Input.GetButtonDown("Jump") && canJump && Mathf.Abs(velocity.y) < 1f && isTouching) { canJump = false; velocity.y = jump * -Mathf.Sign(Physics2D.gravity.y); player.GetComponent <Animator>().SetTrigger("Jumping"); // Jump sound jumpSoundEvent.setParameterValue("JumpPitch", Random.Range(0f, 1f)); jumpSoundEvent.start(); } else if (velocity.y - previousVelocityY > -Mathf.Sign(Physics2D.gravity.y) || Mathf.Approximately(velocity.y, 0f)) { canJump = true; } player.velocity = velocity; previousVelocityY = velocity.y; }
void OnMouseDown() { if (playFlag) { playFlag = false; instance.stop(FMOD.Studio.STOP_MODE.ALLOWFADEOUT); instance.release(); instance = null; } else { if (instance != null) { //instance.stop(FMOD.Studio.STOP_MODE.IMMEDIATE); instance.stop(FMOD.Studio.STOP_MODE.ALLOWFADEOUT); instance.release(); } instance = FMOD_StudioSystem.instance.GetEvent(path); if (instance != null) { var attributes = FMOD.Studio.UnityUtil.to3DAttributes(position); ERRCHECK(instance.set3DAttributes(attributes)); ERRCHECK(instance.setVolume(volume)); instance.setParameterValue("Surface", SurfaceValue); instance.start(); } playFlag = true; } }
protected void PlayCircuitSound(string state) { string sound = null; if (state == "powered") { sound = Sounds.Instance.BuildingPowerOnMigrated; } else if (state == "overdraw") { sound = Sounds.Instance.ElectricGridOverloadMigrated; } else { Debug.Log("Invalid state for sound in EnergyConsumer."); } if (CameraController.Instance.IsAudibleSound(base.transform.GetPosition())) { if (!lastTimeSoundPlayed.TryGetValue(state, out float value)) { value = 0f; } float value2 = (Time.time - value) / soundDecayTime; FMOD.Studio.EventInstance instance = KFMOD.BeginOneShot(sound, CameraController.Instance.GetVerticallyScaledPosition(base.transform.GetPosition())); instance.setParameterValue("timeSinceLast", value2); KFMOD.EndOneShot(instance); lastTimeSoundPlayed[state] = Time.time; } }
void CheckIfObjectIsTouching() { objectIsTouching = Physics2D.OverlapBox(transform.position, transform.localScale, 0, mask); if (objectIsTouching) { RemoveHealth(); isTakingDamage = true; takingDamageInst.setParameterValue("GettingHit", 1); } else { isTakingDamage = false; takingDamageInst.setParameterValue("GettingHit", 0); } }
// Update is called once per frame void FixedUpdate() { if (t) { footEv.setParameterValue("Profondeur", t.getProfondeur()); } float move = Input.GetAxis("Horizontal"); //-1 si joueur appuie sur Q/<- ou 1 si le joueur appuie sur D/-> rb.velocity = new Vector2(speed * move, rb.velocity.y); if (rb.velocity.y < maxVerticalSpeed) { rb.velocity = new Vector2(rb.velocity.x, maxVerticalSpeed); } if (rb.velocity.x > 0 && !facingRight) { Flip(); } else if (rb.velocity.x < 0 && facingRight) { Flip(); } if (!isPlaying && rb.velocity.x != 0) { isPlaying = true; footEv.start(); } else if (isPlaying && rb.velocity.x == 0) { footEv.stop(FMOD.Studio.STOP_MODE.IMMEDIATE); isPlaying = false; } }
// Use this for initialization void Start() { string s = GameManager.instance.getPlayer().getBodyString(); if (s == "Mince") { poids = 1.0f; } else if (s == "Moyen" || s == "Moyenne") { poids = 0.5f; } else if (s == "Gros" || s == "Grosse") { poids = 0.0f; } Debug.Log("Poids " + poids); fs1 = FMODUnity.RuntimeManager.CreateInstance(footStep1); fs1.setParameterValue("Poids", poids); fs2 = FMODUnity.RuntimeManager.CreateInstance(footStep2); fs2.setParameterValue("Poids", poids); j = FMODUnity.RuntimeManager.CreateInstance(jump); d = FMODUnity.RuntimeManager.CreateInstance(down); d.setParameterValue("Poids", poids); a = FMODUnity.RuntimeManager.CreateInstance(attack); Anim = GameObject.Find("body").GetComponent <Animator>(); }
//--------------------------------------- // Use this for initialization void Awake() { if (singleton == null) { singleton = this; } // DontDestroyOnLoad(this.gameObject); UI = GetComponent <UIManager>(); Cursor.visible = false; audioMixer = FMODUnity.RuntimeManager.CreateInstance(audioMixerEvent); audioMixer.start(); audioMixer.setParameterValue("paused", 0); audioMixer.setParameterValue("preRace", 1); audioMixer.setParameterValue("raceFinished", 0); }
private void Play() { MovingEvent = FMODUnity.RuntimeManager.CreateInstance(Moving); FMODUnity.RuntimeManager.AttachInstanceToGameObject(MovingEvent, gameObject.transform, rdbd2d); MovingEvent.setParameterValue("Speed", 0); MovingEvent.start(); isPlaying = true; }
private void OnLanded(object data) { if (!((UnityEngine.Object)CameraController.Instance == (UnityEngine.Object)null)) { Vector3 position = base.transform.GetPosition(); Vector2I vector2I = Grid.PosToXY(position); if (vector2I.x < 0 || Grid.WidthInCells <= vector2I.x || vector2I.y < 0 || Grid.HeightInCells <= vector2I.y) { this.DeleteObject(); } else { Vector2 vector = (Vector2)data; float sqrMagnitude = vector.sqrMagnitude; if (!(sqrMagnitude <= 0.2f) && !SpeedControlScreen.Instance.IsPaused) { Element element = primaryElement.Element; if (element.substance != null) { string text = element.substance.GetOreBumpSound(); if (text == null) { text = (element.HasTag(GameTags.RefinedMetal) ? "RefinedMetal" : ((!element.HasTag(GameTags.Metal)) ? "Rock" : "RawMetal")); } text = ((!(element.tag.ToString() == "Creature") || base.gameObject.HasTag(GameTags.Seed)) ? ("Ore_bump_" + text) : "Bodyfall_rock"); string sound = GlobalAssets.GetSound(text, true); sound = ((sound == null) ? GlobalAssets.GetSound("Ore_bump_rock", false) : sound); if (CameraController.Instance.IsAudibleSound(base.transform.GetPosition(), sound)) { int num = Grid.PosToCell(position); bool isLiquid = Grid.Element[num].IsLiquid; float value = 0f; if (isLiquid) { value = SoundUtil.GetLiquidDepth(num); } FMOD.Studio.EventInstance instance = KFMOD.BeginOneShot(sound, CameraController.Instance.GetVerticallyScaledPosition(base.transform.GetPosition())); instance.setParameterValue("velocity", vector.magnitude); instance.setParameterValue("liquidDepth", value); KFMOD.EndOneShot(instance); } } } } } }
public void PlayStructureFall(GameObject emiter, float size) { FMOD.Studio.EventInstance @event = FMOD_StudioSystem.instance.GetEvent(this.StructureFallEvent); UnityUtil.ERRCHECK(@event.set3DAttributes(UnityUtil.to3DAttributes(emiter, null))); UnityUtil.ERRCHECK(@event.setParameterValue("size", Mathf.Clamp01(size))); UnityUtil.ERRCHECK(@event.start()); UnityUtil.ERRCHECK(@event.release()); }
// Use this for initialization void Start() { chimeLoopInstance = FMODUnity.RuntimeManager.CreateInstance(chimeLoop); chimeLoopInstance.setParameterValue("Release", 0.0f); //FMODUnity.RuntimeManager.PlayOneShot(chimeLoop, transform.position); chimeLoopInstance.start(); }
// Use this for initialization void Start () { cachedRigidBody = GetComponent<Rigidbody>(); openSound = FMODUnity.RuntimeManager.CreateInstance(openEvent); closeSound = FMODUnity.RuntimeManager.CreateInstance(closeEvent); openSound.setParameterValue("Distance", 0.0f); closeSound.setParameterValue("Distance", 0.0f); }
// Start is called before the first frame update void Start() { introScreenEffect = FMODUnity.RuntimeManager.CreateInstance(introScreenSound); FMODUnity.RuntimeManager.AttachInstanceToGameObject(introScreenEffect, GetComponent <Transform>(), GetComponentInParent <Rigidbody>()); introScreenEffect.setParameterValue("start", 0f); introScreenEffect.start(); }
public void SetParameter(string paramName, float value) { FMOD.RESULT r = _audio.setParameterValue(paramName, value); if (r != FMOD.RESULT.OK) { throw new NullReferenceException("Audio parameter <" + paramName + "> not found in audio"); } }
private void PlayFallEvent(float fallParameterValue) { FMOD.Studio.EventInstance @event = FMOD_StudioSystem.instance.GetEvent(this.fallEvent); UnityUtil.ERRCHECK(@event.setParameterValue("fall", fallParameterValue)); UnityUtil.ERRCHECK(@event.set3DAttributes(UnityUtil.to3DAttributes(base.gameObject, null))); UnityUtil.ERRCHECK(@event.start()); UnityUtil.ERRCHECK(@event.release()); }
private void Update() { if (this.Remote) { return; } PLAYBACK_STATE pLAYBACK_STATE = PLAYBACK_STATE.STOPPED; if (this.musicTrack != null) { UnityUtil.ERRCHECK(this.musicTrack.getPlaybackState(out pLAYBACK_STATE)); } if (pLAYBACK_STATE != PLAYBACK_STATE.STOPPED) { PlayerSfx.MusicPlaying = true; } else { PlayerSfx.MusicPlaying = false; } if (base.transform.hasChanged) { base.transform.hasChanged = false; ATTRIBUTES_3D attributes = UnityUtil.to3DAttributes(this.SfxPlayer, null); PlayerSfx.Set3DAttributes(this.staminaBreathInstance, attributes); PlayerSfx.Set3DAttributes(this.walkyTalkyInstance, attributes); PlayerSfx.Set3DAttributes(this.musicTrack, attributes); PlayerSfx.Set3DAttributes(this.afterStormInstance, this.SfxPlayer.transform.position.to3DAttributes()); } if (this.afterStormInstance != null && !this.afterStormInstance.isValid()) { this.afterStormInstance = null; } Vector3 vector = (base.GetComponent <Rigidbody>().position - this.prevPosition) / Time.deltaTime; this.prevPosition = base.GetComponent <Rigidbody>().position; Vector3 vector2 = new Vector3(vector.x, 0f, vector.z); this.flatVelocity = vector2.magnitude; if (!this.Buoyancy.InWater) { this.immersed = false; } else if (!this.immersed && !LocalPlayer.FpCharacter.Grounded && LocalPlayer.FpCharacter.IsAboveWaistDeep()) { this.immersed = true; float num = Mathf.Clamp(this.SplashSpeedMaximum - this.SplashSpeedMinimum, 0f, this.SplashSpeedMaximum); float num2 = (this.Buoyancy.LastWaterEnterSpeed - this.SplashSpeedMinimum) / num; if (num2 >= 0f) { FMOD.Studio.EventInstance @event = FMOD_StudioSystem.instance.GetEvent(this.SplashEvent); UnityUtil.ERRCHECK(@event.set3DAttributes(UnityUtil.to3DAttributes(this.SfxPlayer, null))); UnityUtil.ERRCHECK(@event.setParameterValue("speed", Mathf.Clamp01(num2))); UnityUtil.ERRCHECK(@event.start()); UnityUtil.ERRCHECK(@event.release()); } } }
// Update is called once per frame void Update() { if (Input.GetKeyDown(KeyCode.C)) { PlayOneShotSound(); } else if (Input.GetKeyDown(KeyCode.M)) { PlayTrackedOneShotSound(); } //This Controls the Television Loop Sound if (Input.GetKey(KeyCode.Y)) { //manage sustained sound if (!turnedOnTV) { tvEvent.setParameterValue("TelevisionOff", 0f); turnedOnTV = true; Debug.Log("Turned On TV"); tvEvent.start(); } } else if (Input.GetKeyUp(KeyCode.Y)) { //when i release the key, i turn off the tv tvEvent.setParameterValue("TelevisionOff", 1.0f); turnedOnTV = false; } if (Input.GetKeyDown(KeyCode.K)) { playerCoolness++; //Attach to FMOD Parameter } //todo -- //have the following functions working for the demo on Monday: //pressing C does the vhs sound as a one shot (unattached) //pressing M does the vhs sound as a one shot (attached) //pressing and holding Y goes through an AHDSR - esque curve //pressing K increases coolness, which adjusts a global audio effect }
public void RemoveMiko() { EvilMiko.SetActive(false); emitter.Stop(); FMOD.Studio.EventInstance music = FMODUnity.RuntimeManager.CreateInstance("event:/BackgroundMusic"); music.setParameterValue("NormalTown", 1f); music.start(); StartCoroutine(MoveCredits()); }
// Update is called once per frame void Update() { if (ShouldTransitionToBassoonPart && SceneManagementScript.BackgroundMusicLayersFadeValue < 4) { SceneManagementScript.BackgroundMusicLayersFadeValue += 0.005f; TitleScreenMusic.setParameterValue("BackgroundMusicLayerManageValue", SceneManagementScript.BackgroundMusicLayersFadeValue); } }
private void Start() { footstepsEV = FMODUnity.RuntimeManager.CreateInstance(footstepsRef); footstepsEV.start(); footstepsEV.setParameterValue(footstepsParameterName, muteSteps); gliderWindEV = FMODUnity.RuntimeManager.CreateInstance(gliderWindRef); gliderWindEV.start(); }
// Use this for initialization void Start() { cachedRigidBody = GetComponent <Rigidbody>(); openSound = FMODUnity.RuntimeManager.CreateInstance(openEvent); closeSound = FMODUnity.RuntimeManager.CreateInstance(closeEvent); openSound.setParameterValue("Distance", 0.0f); closeSound.setParameterValue("Distance", 0.0f); }
// Use this for initialization void Start() { rb2D = GetComponent <Rigidbody2D>(); animator = GetComponentInChildren <Animator>(); slash.SetActive(false); walk = FMODUnity.RuntimeManager.CreateInstance(PlayerWalk); walk.start(); walk.setParameterValue("speed", 0); }
// Use this for initialization void Start () { breathSound = FMODUnity.RuntimeManager.CreateInstance(breathEvent); breathSound.setParameterValue("stamina", 1.0f); breathSound.start(); heartbeatSound = FMODUnity.RuntimeManager.CreateInstance(heartbeatEvent); heartbeatSound.setParameterValue("stamina", 1.0f); heartbeatSound.start(); }
void Update() { if (hasLevelEnded) { playerFootsteps.setParameterValue("velocity", 0); return; } float horizontal = Input.GetAxis(Constants.PLAYER_HORIZONTAL_INPUT) * speed; float vertical = Input.GetAxis(Constants.PLAYER_VERTICAL_INPUT) * speed; Vector3 velocity = new Vector3(horizontal, vertical, 0); if (velocity.magnitude > 0) { playerFootsteps.setParameterValue("velocity", 1); } else { playerFootsteps.setParameterValue("velocity", 0); } animator.SetBool(Constants.ANIMATION_TRANSITION_MOVE, (velocity.magnitude > 0)); characterController.Move(velocity); transform.rotation = Quaternion.LookRotation( Vector3.RotateTowards( transform.forward, velocity, rotationSpeed * Time.deltaTime, 0f ), Vector3.forward ); Vector3 eulerAngles = transform.rotation.eulerAngles; eulerAngles = new Vector3(0, 0, eulerAngles.z); transform.rotation = Quaternion.Euler(eulerAngles); if (invincibleTimeLeft > 0) { CountDownInvincibility(); } }
// Use this for initialization void Start() { gM = FindObjectOfType <GameManager>(); mM = FindObjectOfType <MusicManager>(); takingDamageInst = FMODUnity.RuntimeManager.CreateInstance(takingDamageSound); takingDamageInst.start(); takingDamageInst.setParameterValue("GettingHit", 0); }
void Start() { fmodevent = FMOD_StudioSystem.instance.GetEvent("event:/music/music"); if (fmodevent != null) { fmodevent.setVolume(1.0f); fmodevent.setParameterValue("music_trans", 0.0f); fmodevent.start(); } }
// Use this for initialization void Start () { cachedRigidBody = GetComponent<Rigidbody>(); yakAliveSound = FMODUnity.RuntimeManager.CreateInstance(yakAliveEvent); yakAliveSound.setParameterValue("Distance", 0.0f); yakAliveSound.start(); yakDeathSound = FMODUnity.RuntimeManager.CreateInstance(yakDeathEvent); yakRunAway = new YakRunAway(this, runAwayStepSize); yakFollowWaypoints = new YakFollowWaypoints(this); agent = GetComponent<NavMeshAgent>(); this.setFollowWaypoints(); }
#endregion public bool intro; void Awake() { originalPosition = Camera.main.transform.position; firstBison = true; if (Instance == null)Instance = this; else { if (this != Instance) Destroy(this.gameObject); } StartCoroutine(SpawnAnimal()); music = RuntimeManager.CreateInstance ("event:/Music"); music.start(); music.setParameterValue("Tension", 0); countdown = RuntimeManager.CreateInstance("event:/Sounds/Level_Select_Countdown");
void InitStormSndEvt() { stormSoundEvt = FMODUnity.RuntimeManager.CreateInstance("event:/ocean"); stormSoundEvt.setParameterValue("StormLevel", weatherFade); stormSoundEvt.start(); }