Immerse SDK
Toggle Dark/Light/Auto mode Toggle Dark/Light/Auto mode Toggle Dark/Light/Auto mode Back to homepage

Audio Tags

Audio tags can be used to filter voice chat within a session, enabling features such as smaller group discussions or simulating one-way communication (e.g. a PA system).

To create an audio tag, navigate to the Unity create menu: Create > Immerse > Multiplayer > Audio Tag. Once created, the audio tag asset must be registered in the Immerse multiplayer settings before it can be assigned to a user.

Audio tags

If the ‘Is Default’ property on an audio tag asset is enabled, the tag will automatically be assigned to users when they join the session. The description field is for developer reference.

Global audio tag

Assigning & Unassigning

To assign or unassign audio tags for a user, you need to create an AudioTagRequest. The default constructor will create a request for the local user and populate the Listen and Speak lists with their current audio tags. You can then modify these lists to specify which tags you want the user to speak or listen to. Finally, call the Apply() method to apply the changes.

Since the Listen and Speak lists refer to the IDs of the audio tags, methods have been added to allow the use of the audio tag asset directly. See the example below:

using ImmerseSDK.Multiplayer.Voice.AudioTags;

// Start listening and speaking to an audio tag
var request = new AudioTagRequest();
request.AddListening(audioTag)
request.AddSpeaking(audioTag);
request.Apply();

// Stop listening to an audio tag
var request.RemoveListening(audioTag);
request.Apply();
Always remember to Apply() your changes

Clear Tags

If you want to start with a clean slate, you can clear the Listen and Speak lists to remove all current audio tags. This allows you to begin fresh and add only the tags you need.

using ImmerseSDK.Multiplayer.Voice.AudioTags;

// Create new request and clear existing tags
var request = new AudioTagRequest();
request.Listen.Clear();
request.Speak.Clear();

// Add new tags and apply
request.AddListening(audioTag);
request.Apply();

Other Users

You can also change audio tags for other users by using an overload of the AudioTagRequest constructor, which requires specifying the network client and the target user.

This allows you to manage audio tags for any user in the session, providing flexibility in configuring voice chat settings across different users.

using ImmerseSDK.Multiplayer.Voice.AudioTags;

// Create an audio tag request for another user
var request = new AudioTagRequest(ImmerseMultiplayer.Client, user);
...
request.Apply();

Shorthand

A shorthand method, similar to StringBuilder, also exists, which can result in cleaner and more concise code.

This shorthand approach streamlines the process of managing audio tags, making the code more readable and easier to maintain.

using ImmerseSDK.Multiplayer.Voice.AudioTags;

new AudioTagRequest().AddListening(audioTag).AddSpeaking(audioTag).Apply();