How Do I Use Photon Voice 2 with Bolt?

in Photon Voice
I'm developing a multiplayer VR app in Unity 2019.4.4f1 in the Android platform for the Oculus Quest. I haven't been able to find any tutorials or other guidance for setting up Photon Voice 2 with Bolt. I reviewed the documentation for Voice 2 and see a page called "Voice for PUN 2" as well as "PUN Voice Demo" tutorial, but no guidance specifically for Voice 2 and Bolt. And I couldn't find any applicable demo scenes in the Photon assets installed in my Unity project.
Can anyone provide guidance? Thanks!
Can anyone provide guidance? Thanks!
0
Best Answers
-
Hello @OjosLindos ,
I've managed to get Bolt with Voice working with a minimum setup, but you would need to modify it if you need something more specific.
Here are the steps:
1. Import Photon Bolt into your project
2. Import Photon Voice 2:
2.1 When importing uncheck "PhotonLibs" and "PhotonRealtime" folders, as they already exist on the Bolt SDK;
2.2 Remove PUN and Photon Chat from the project (instructions here and here)
2.3 It may be necessary to restart Unity, if there are any errors that can't be cleared.
3. Follow the instructions of "How to use Voice without PUN" here or you can take as base the GameObject "Voice Connection and Recorder" found on the "DemoVoiceMinimal-Scene" scene. Just transform it into a Prefab, and create a new "Speaker" prefab with the "Speaker" script, as described on the instructions.
4. Now, you just need to put the "Voice Connection and Recorder" into your Bolt game scene. When you start the server, and connect with another client, Bolt will run as usual, and the Voice prefab will take care of connecting the players to a random room by default. Now you have a minimal working sample with Bolt and Voice.
5. In order to customize how the clients will communicate, and most importantly, to make them connect to the same room, you need to take a look at the "ConnectAndJoin" script. You can, for example, use the game session ID (example "MyGame_1234") that you've used to create the Bolt game in order to identify the Voice Room ("MyGame_Voice_1234") and pass this to the script, so all players enter the same session for voice.
Keep in mind that you need 2 separate connections with Photon, one for Bolt, using an exclusive App ID for it, and another for Voice, also using a specific App ID for Voice. You will also need to create two Photon sessions (rooms), one for each SDK.
--
Ramon Melo
Photon Bolt Team6 -
Hi @OjosLindos,
for positional audio, if you place the Speaker component on your moving character avatar per player then all you need is to tweak Unity's 3D audio settings via AudioSource component on the same GameObject as the Speaker.
See AudioSource.spatialBlend, maxDistance, etc.5
Answers
-
Hello @OjosLindos ,
I've managed to get Bolt with Voice working with a minimum setup, but you would need to modify it if you need something more specific.
Here are the steps:
1. Import Photon Bolt into your project
2. Import Photon Voice 2:
2.1 When importing uncheck "PhotonLibs" and "PhotonRealtime" folders, as they already exist on the Bolt SDK;
2.2 Remove PUN and Photon Chat from the project (instructions here and here)
2.3 It may be necessary to restart Unity, if there are any errors that can't be cleared.
3. Follow the instructions of "How to use Voice without PUN" here or you can take as base the GameObject "Voice Connection and Recorder" found on the "DemoVoiceMinimal-Scene" scene. Just transform it into a Prefab, and create a new "Speaker" prefab with the "Speaker" script, as described on the instructions.
4. Now, you just need to put the "Voice Connection and Recorder" into your Bolt game scene. When you start the server, and connect with another client, Bolt will run as usual, and the Voice prefab will take care of connecting the players to a random room by default. Now you have a minimal working sample with Bolt and Voice.
5. In order to customize how the clients will communicate, and most importantly, to make them connect to the same room, you need to take a look at the "ConnectAndJoin" script. You can, for example, use the game session ID (example "MyGame_1234") that you've used to create the Bolt game in order to identify the Voice Room ("MyGame_Voice_1234") and pass this to the script, so all players enter the same session for voice.
Keep in mind that you need 2 separate connections with Photon, one for Bolt, using an exclusive App ID for it, and another for Voice, also using a specific App ID for Voice. You will also need to create two Photon sessions (rooms), one for each SDK.
--
Ramon Melo
Photon Bolt Team6 -
Thanks, @ramonmelo! I'll try this out. Do you have any further guidance for making the voice chat positional? In other words, I'd like the voice chat volume to drop off as the players get farther away from each other.0
-
Hi @OjosLindos,
for positional audio, if you place the Speaker component on your moving character avatar per player then all you need is to tweak Unity's 3D audio settings via AudioSource component on the same GameObject as the Speaker.
See AudioSource.spatialBlend, maxDistance, etc.5 -
Thanks so much! I'll let you know if I need further assistance.0
-
I can't get the voice chat to be positional. I added a "Voice Connection and Recorder" game object from the "DemoVoiceMinimal-Scene" scene to my scene. I didn't add a Speaker prefab to the Voice Connection component, but added Speaker/Audio Source components to the player prefab which gets instantiated for each player over Photon Bolt. The players can hear each other but not positionally even though I've tried a variety of settings relating to 3D sound, etc., in the Audio Source component on the player prefab. Do you have any idea why the voice chat still isn't positional?0
-
I think I found out how to set up Photon Voice 2 with Bolt in my project so that it works positionally:
1. Unlike in my last post, I didn't add Speaker/Audio Source components to the player prefab which Bolt instantiates. Instead, I added a Speaker prefab with those components to the Voice Connection component (dragged it into the slot).
2. I added a script to the Speaker prefab so that, when it's instantiated, it attaches itself to the remote player prefab, specifically to an empty game object child called "Speaker Target Location". Here's my script (in theory this will work with more than 2 players, i.e., so the right Speaker prefabs get attached to the right player prefabs):
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class SpeakerPrefabManagerVoice2BoltTest : MonoBehaviour
{
GameObject targetLocation;
void Start()
{
Invoke("RelocateSpeaker", 3);
}
/*void Update()
{
}*/
void RelocateSpeaker()
{
targetLocation = GameObject.FindWithTag("Speaker Target Location");
transform.parent = targetLocation.transform;
targetLocation.tag = "Untagged";
}
}
3. I added an Audio Listener to the local player (but only to the local player).
4. In the Audio Source component of the Speaker prefab I set Spatial Blend to full 3D. I believe this is necessary for the sound to attenuate as the players get farther away from each other. Other Audio Source settings can also be tweaked.
The positional voice chat now works fine. Photon developer support told me they're "building a full integration of Bolt with Voice that will include a sample for spatial audio". But until that's available maybe my approach will be of assistance to someone.1