Avatar sound
How can I turn down the volume of an avatar and implement it with an slider to do so.
RealtimeAvatarVoice component. Here's how you can approach this:RealtimeAvatarVoice component is responsible for handling voice chat in NormalVR avatars Documentation > Realtime > Xr > Voice Chat (https://normcore.io/documentation/realtime/xr/voicechat).AudioSource component that RealtimeAvatarVoice uses for playback.RealtimeAvatarVoice component of the avatar you want to control and the UI Slider you've created.RealtimeAvatarVoice creates an AudioSource component automatically if one doesn't exist, but you can also create one manually for more control over audio settings Documentation > Realtime > Xr > Voice Chat (https://normcore.io/documentation/realtime/xr/voicechat).RealtimeComponent to synchronize the volume setting across all clients. For more information on synchronizing custom data, refer to the Synchronizing Custom Data (https://normcore.io/documentation/realtime/synchronizing-custom-data#faq) documentation.using UnityEngine;
using Normal.Realtime;
using UnityEngine.UI;
public class AvatarVolumeControl : MonoBehaviour
{
public RealtimeAvatarVoice avatarVoice;
public Slider volumeSlider;
private AudioSource audioSource;
void Start()
{
// Get the AudioSource component
audioSource = avatarVoice.GetComponent<AudioSource>();
// Set up the slider
volumeSlider.onValueChanged.AddListener(ChangeVolume);
// Initialize slider value
volumeSlider.value = audioSource.volume;
}
void ChangeVolume(float volume)
{
if (audioSource != null)
{
audioSource.volume = volume;
}
}
}