public override void Play(NVRCollisionSoundMaterials material, Vector3 position, float impactVolume) { if (material == NVRCollisionSoundMaterials.none) { return; } if (NVRCollisionSoundController.Instance.PitchModulationEnabled) { AudioPool[CurrentPoolIndex].pitch = Random.Range(1 - NVRCollisionSoundController.Instance.PitchModulationRange, 1 + NVRCollisionSoundController.Instance.PitchModulationRange); } AudioPool[CurrentPoolIndex].transform.position = position; AudioPool[CurrentPoolIndex].volume = impactVolume; AudioPool[CurrentPoolIndex].clip = GetClip(material); AudioPool[CurrentPoolIndex].Play(); CurrentPoolIndex++; if (CurrentPoolIndex >= AudioPool.Length) { CurrentPoolIndex = 0; } }
public static void Play(NVRCollisionSoundMaterials material, Vector3 position, float impactVolume) { if (Provider != null) { Provider.Play(material, position, impactVolume); } }
private AudioClip GetClip(NVRCollisionSoundMaterials material) { if (Clips.ContainsKey(material) == false) { material = NVRCollisionSoundMaterials._default; Debug.LogError("[NewtonVR] CollisionSound: Trying to play sound for material without a clip. Need a clip at: " + CollisionSoundsPath + "/" + material.ToString()); } int index = Random.Range(0, Clips[material].Count - 1); return(Clips[material][index]); }
public override void Play(NVRCollisionSoundMaterials material, Vector3 position, float impactVolume) { if (material == NVRCollisionSoundMaterials.none) { return; } System.Guid playGuid = EventGuids[material]; EventInstance collidingInstance = RuntimeManager.CreateInstance(playGuid); collidingInstance.set3DAttributes(RuntimeUtils.To3DAttributes(position)); collidingInstance.setVolume(impactVolume); collidingInstance.start(); collidingInstance.release(); }
public override void Play(NVRCollisionSoundMaterials material, Vector3 position, float impactVolume) { if (!mWwiseAvailable) { return; } if (material == NVRCollisionSoundMaterials.none) { return; } string event_name = EventStrings[material]; AkGameObj game_obj = AudioPool[CurrentPoolIndex]; CurrentPoolIndex++; if (CurrentPoolIndex >= AudioPool.Length) { CurrentPoolIndex = 0; } game_obj.gameObject.SetActive(true); Collider collider = game_obj.GetComponent <Collider>(); if (collider != null) { collider.enabled = true; } if (showCollisions) { MeshRenderer renderer = game_obj.GetComponent <MeshRenderer>(); if (renderer != null) { renderer.enabled = true; } } // // Position the object and post the event. // game_obj.transform.position = position; // // use the impactVolume to control the sound // float impact_value = impactVolume * 100.0f; //Debug.Log("impactVolume = " + impactVolume); AkSoundEngine.SetRTPCValue(mImpactVolumeControlId, impact_value, AudioPool[CurrentPoolIndex].gameObject); //Debug.Log("Position in Unity: " + AudioPool[CurrentPoolIndex].transform.position + // " position in Wise: " + AudioPool[CurrentPoolIndex].GetPosition()); uint res = AkSoundEngine.PostEvent(event_name, AudioPool[CurrentPoolIndex].gameObject, (uint)AkCallbackType.AK_EndOfEvent, DisableGameObjectCallback, game_obj); if (res == AkSoundEngine.AK_INVALID_PLAYING_ID) { // // Failed to play the sound // DisableGameObject(game_obj); } }
public override void Play(NVRCollisionSoundMaterials material, Vector3 position, float impactVolume) { return; }
public abstract void Play(NVRCollisionSoundMaterials material, Vector3 position, float impactVolume);