Forum Discussion
rex.gatling.963
7 months agoProtege
Amplify Sound
I am trying to amplify the Meta Avatar's Audiosource using ontriggerenter. Basically I need for everyone in the game to hear the player in that trigger zone throughout the entire world. Can anybody help? I am using one of the Meta Audio Example projects but don't know exactly what to do to accomplish this.
3 Replies
Replies have been turned off for this discussion
- Barty98Explorer
You could add this to your OnTriggerEnter which will make the audio source 2D and play at full volume:
audioSource.spatialBlend = 0fIf you want to keep the audio directional then just tweak the min and max distance of the audio source.
- rex.gatling.963Protege
Here is the script. It is meant to pick up the Meta Avatar Voice. Is this correct? Because even when I using the triggerzone and the trigger is checked on the zone it doesn't amplify. Is there something on the editor I need to adjust?
using UnityEngine;using Normal.Realtime;public class AutoAmplify : MonoBehaviour{private RealtimeAvatarVoice _avatarVoice;private AudioSource _audioSource;void Awake(){_avatarVoice = GetComponentInChildren<RealtimeAvatarVoice>();if (_avatarVoice != null){_audioSource = _avatarVoice.GetComponent<AudioSource>();}}void OnTriggerStay(Collider other){if (other.CompareTag("Stage") && _audioSource != null){// Store the previous volume for comparisonfloat previousVolume = _audioSource.volume;// Amplify the volume to the maximum_audioSource.volume = 1.0f;_audioSource.spatialBlend = 0f;// Log the volume changeDebug.Log($"AutoAmplify triggered for {other.gameObject.name}. Volume changed from {previousVolume} to {_audioSource.volume}");}}}- Barty98Explorer
Are you getting the debug logs that show the code is actually running? If you want to audio to be louder I believe you will need to use an Audio Mixer.
Also I believe you want to use OnTriggerEnter instead of OnTriggerStay, then reset your audio settings in OnTriggerExit.
Quick Links
- Horizon Developer Support
- Quest User Forums
- Troubleshooting Forum for problems with a game or app
- Quest Support for problems with your device
Other Meta Support
Related Content
- 2 months ago