Positional channel configuration
Configure positional channels for spatial audio in 3D environments.
Read time 1 minuteLast updated 2 days ago
If a game has joined a positional channel, it must frequently update the Vivox SDK with the position and orientation of the user in the 3D space that is associated with that channel. The client does this by calling the
VivoxService.Instance.Set3DPosition(GameObject participantObject, string channelName)channelName
A participant's location in a positional channel affects who they can hear and the perceived loudness and direction of other players’ voices. With text enabled, location limits the delivery of text messages to only users within the audible vicinity of the sender.
Positional channels use a right-hand coordinate system. When the player avatar is standing facing directly forward, the following criteria applies:
- The positive X-axis is to the avatar's right.
- The positive Y-axis runs from the avatar's feet upward through their head.
- The positive Z-axis runs from the avatar's chest out through their back.
After you set up and join a positional channel with any configured 3D properties, you then report your actor's position and orientation to the Vivox SDK. The best practice recommendation is to update the users position 2-4 times per second.
The following code is an example of how to set a user's position in a positional channel:
This sample code demonstrates methods to limit the number of 3D positional updates that are sent. For example, a time tracking technique in the update method can rate limit update attempts to a reasonable number of times per second. In the sample methodusing UnityEngine;using Unity.Services.Vivox;class PositionalChannelExample : MonoBehaviour{ . . . // For this example, _nextPosUpdate has been initialized as Time.time at // game start. _localPlayerGameObject is the GameObject controlled by the local player. void Update() { . . . if (Time.time > _nextPosUpdate) { VivoxService.Instance.Set3DPosition(_localPlayerGameObject, activePositionalChannelName); _nextPosUpdate += 0.3f; // Only update after 0.3 or more seconds } . . . } . . .}
Update3DPositionSet3DPosition