Audio Tags
Audio tags can be used to filter voice chat within a session. For example, if you want to have a discussion in smaller groups within a session or if you wanted to simulate one way communication such as a PA system.
Each audio tag must be defined in the Immerse SDK Voice foldout in Project Settings. Audio tags must be unique and changes must be pushed to the platform before they will become available. This can be done by pressing the Update Project button or uploading a new build that contains an updated metadata.json file.
By setting the Is Default
option, this audio tag will be added to all new users as they connect to a session. Users with no audio tags will not be able to hear or speak to anyone else in the session.
Having no audio tags assigned is treated as it’s own tag. i.e. Uses that have no listening tags will hear users that have no speaking tags.
The most direct way to control audio tags is by creating an AudioTagChangeRequest
. Below is an example script that contains example methods showing how to listen and speak to an audio tag.
using ImmerseSDK.PlatformServices.Voice.AudioTags;
using UnityEngine;
/// <summary>
/// Example methods that show how to enable/disable listening and speaking to audio tags
/// </summary>
public class AudioTagsExample : MonoBehaviour
{
[SerializeField]
[Tooltip("Name of the audio tag")]
private string _audioTag = "Global";
/// <summary>
/// Start listening to the audio tag
/// </summary>
public void EnableListening()
{
var descriptor = new AudioTagChangeRequest();
descriptor.ListenTo(_audioTag);
descriptor.SendChangeRequest();
}
/// <summary>
/// Stop listening to the audio tag
/// </summary>
public void DisableListening()
{
var descriptor = new AudioTagChangeRequest();
descriptor.StopListeningTo(_audioTag);
descriptor.SendChangeRequest();
}
/// <summary>
/// Start speaking to the audio tag
/// </summary>
public void EnableSpeaking()
{
var descriptor = new AudioTagChangeRequest();
descriptor.SpeakTo(_audioTag);
descriptor.SendChangeRequest();
}
/// <summary>
/// Stop speaking to the audio tag
/// </summary>
public void DisableSpeaking()
{
var descriptor = new AudioTagChangeRequest();
descriptor.StopSpeakingTo(_audioTag);
descriptor.SendChangeRequest();
}
/// <summary>
/// Start listening AND speaking to the audio tag
/// </summary>
public void JoinAudioTag()
{
var descriptor = new AudioTagChangeRequest();
descriptor.ListenTo(_audioTag);
descriptor.SpeakTo(_audioTag);
descriptor.SendChangeRequest();
}
/// <summary>
/// Stop listening AND speaking to the audio tag
/// </summary>
public void LeaveAudioTag()
{
var descriptor = new AudioTagChangeRequest();
descriptor.StopListeningTo(_audioTag);
descriptor.StopSpeakingTo(_audioTag);
descriptor.SendChangeRequest();
}
}
Audio tags can also be controlled using the AudioTagVolume
component. This component is designed to change a user’s audio tags when their avatar enters/exits a trigger collider.
The example shows how to set up an audio tag volume that will allow a user to speak and listen to the ‘Red’ audio tag when their avatar enters the box collider and will remove these audio tags when leaving.
Field | Description |
---|---|
Audio Tag Behaviour | Additive: Add the listed audio tags when enteringSubtract: Remove the listed audio tags when enteringSet: Remove all audio tags, apart from those listed, when entering |
Reverse on Exit | If the enter behaviour should be reversed when the avatar exits.(This option is not available with the Set behaviour) |
Speaking Audio Tags | Speaking audio tags to be changed |
Listening Audio Tags | Listening audio tags to be changed |