Photon Voice - UserId is empty, connects but can't bind players

Options
I have this project to deliver, it's a simple one: one player creates a room, then other players enter this room. The room creator can manipulate one object, the other players, only see the manipulation result (simple transformations). Also, the room creator can transmit voice to the other players.

I followed the tutorial for Photon PUN 2, and set up the game as instructed. The networking part is working fine, the room is created, players connect, and the object is synchronized with everyone.

The problem is with Photon voice. I also followed the instructions, and set it all up. Apparently, it connects, but the UserId is sent empty to the connecting player, which doesn't let voice to be sent.

Could you help me in figuring out what part of the setup and/or initialization process I'm missing? Tried searching the forums already, looked into source code, but I'm out of clues.

Here is my configuration:

Photon Server Settings:
Photon Server Settings

Photon Voice Network and Recorder:
Photon Voice Network and Recorder

A Photon View (don't know how necessary it is):
Photon View

And this is the basic initialization code:

public class PhotonController : MonoBehaviourPunCallbacks
{
....string gameVersion = "1";
....string roomName = "baseRoom";
....public byte maxPlayersPerRoom = 4;

....private void Awake()
....{
........PhotonNetwork.AutomaticallySyncScene = true;
........DontDestroyOnLoad(gameObject);
....}

....void Start()
....{
........PhotonNetwork.GameVersion = gameVersion;
........PhotonNetwork.ConnectUsingSettings();
....}

....public override void OnConnectedToMaster()
....{
........base.OnConnectedToMaster();
........// opens UI, waiting for user to create or join room
....}

....// Button to create room
....public void _StartServer()
....{
........if (PhotonNetwork.IsConnected)
........{
............GlobalSettings.iAmServer = true;
............PhotonNetwork.CreateRoom(roomName, new RoomOptions { MaxPlayers = maxPlayersPerRoom });
........}
....}

....// Button to join room
....public void _StartClient()
....{
........GlobalSettings.iAmServer = false;
........PhotonNetwork.JoinRoom(roomName);
....}

....public override void OnJoinedRoom()
....{
........myRecorder = GetComponent<Recorder>();

........// only the server can transmit voice
........if (GlobalSettings.iAmServer)
........{
............myRecorder.Init(PhotonVoiceNetwork.Instance.VoiceClient);
............myRecorder.TransmitEnabled = true;
........}

........base.OnJoinedRoom();
....}
}


(how do you format code in this editor? :tongue: )

Edit: forgot to put the logs:

Server logs (room creator and host, run in Editor)

Received your UserID from server. Updating local value to: 00158bc7-54d9-4e02-a35e-a8d0bce5016f

(Filename: Assets/Scripts/Photon/PhotonController.cs Line: 74)

[Photon Voice Controller.PhotonVoiceNetwork] PUN joined room, now connecting Voice client

Created room

Joined room

(Filename: Assets/Scripts/Photon/MotorPhotonSpawner.cs Line: 19)

[Photon Voice Controller.Recorder] Setting recorder's source to Photon microphone device -1

[Photon Voice Controller.Recorder] Setting recorder's source to WindowsAudioInPusher

Refreshing native plugins compatible for Editor in 1.01 ms, found 14 plugins.
[PV] Local voice #1 audio source frequency 16000 and encoder sampling rate 24000 do not match. Resampling will occur

before encoding.

(Filename: Assets/Photon/PhotonRealtime/Code/LoadBalancingClient.cs Line: 1830)

[PV] Local v#1 ch#1 added enc: c=AudioOpus f=24000 ch=1 d=20000 s=480 b=30000 w=0 h=0 ud=

[PV] Local v#1 ch#1: Starting data encode thread

Received your UserID from server. Updating local value to: f39504c6-a2f6-458e-8660-a12f82e82cd9

[Photon Voice Controller.PhotonVoiceNetwork] PUN joined room, now joining Voice room

[PV] Remote voices cleared

[PV] Local v#1 ch#1 Sending info: c=AudioOpus f=24000 ch=1 d=20000 s=480 b=30000 w=0 h=0 ud= ev=0

[PV] Local v#1 ch#1 Sending info: c=AudioOpus f=24000 ch=1 d=20000 s=480 b=30000 w=0 h=0 ud= ev=94
[PV] Remote voices cleared

[Photon Voice Controller.PhotonVoiceNetwork] PUN joined room, now connecting Voice client

[PV] Local v#1 ch#1: Exiting data encode thread

Disconnected
DisconnectByClientLogic

[PV] Local v#1 ch#1 removed


Client logs (participant, run in Editor)

Received your UserID from server. Updating local value to: 404d1ed3-745c-4340-a4ea-8e7901b95167

[Photon Voice Controller.PhotonVoiceNetwork] PUN joined room, now connecting Voice client

Joined room

Received your UserID from server. Updating local value to: f7fe61f4-ed11-4099-a89b-2ccb4103b1b2

[Photon Voice Controller.PhotonVoiceNetwork] PUN joined room, now joining Voice room

[PV] Remote voices cleared

[PV] Frame event for voice #1 of not inited channel 1

[PV] Frame event for voice #1 of not inited channel 1

[PV] Frame event for voice #1 of not inited channel 1

[PV] Frame event for voice #1 of not inited channel 1

[PV] Frame event for voice #1 of not inited channel 1

[PV] Frame event for voice #1 of not inited channel 1

[PV] ch#1 p#1 v#1 Info received: c=AudioOpus f=24000 ch=1 d=20000 s=480 b=30000 w=0 h=0 ud= ev=124

[Photon Voice Controller.PhotonVoiceNetwork] OnRemoteVoiceInfo channel 1 player 1 voice #1 userData
(Filename: Assets/Photon/PhotonVoice/Code/VoiceLogger.cs Line: 92)

[Photon Voice Controller.PhotonVoiceNetwork] UserData (null) does not contain PhotonViewId. Remote voice 1/1 not linked

[PV] Remote v#1 ch#1 p#1: Starting decode thread

[Photon Voice Controller.PhotonVoiceNetwork] PUN left room, disconnecting Voice

Disconnected
DisconnectByClientLogic

[PV] Remote v#1 ch#1 p#1: Exiting decode thread

[PV] Remote voices cleared

Best Answer

Answers

  • JohnTube
    JohnTube ✭✭✭✭✭
    Options
    Hi @Suspensorio,

    Thank you for choosing Photon!

    The title of this discussion is misleading.
    The issue is not about UserId but "UserData" as the error log states:
    UserData (null) does not contain PhotonViewId. Remote voice 1/1 not linked
    What this error says and what the last screenshot shows is that you are not using the PhotonVoiceView correctly or you are not instantiating a PUN prefab (that has PhotonView attached to it using PhotonNetwork.Instantiate) at all! I think maybe you attached the PhotonVoiceView to a scene object which is not supported by Photon Voice. You need to instantiate a prefab per player as an avatar/character that has a player owned PhotonView and to which you attach a PhotonVoiceView.
  • Hi @JohnTube, thanks for the answer!

    I tried something like that just now, but I got the same error.
    There is a prefab with PhotonView, PhotonVoiceView, Recorder, Speaker and AudioSource, hopefully all configured correctly. This prefab is instantiated inside OnJoinedRoom, using PhotonNetwork.Instantiate. A bit later, I set the primary recorder to que one in the instantiated prefab, and try to init the Recorder.

    What would be the correct flow to instantiate a player with a PhotonVoiceView? I don't need any mechanics on this player, since they are only viewers or act on the world indirectly, so it can be as simple as needed.
  • Thanks a lot, @JohnTube! I finally got it working now. And Photon is wonderful, as soon as I got that problem solved and another with TransmitEnabled, everything just work! :smiley:

    I think this kind of information should be on the docs on the website. It's a very specific workflow behind-the-scenes, people implementing Voice should know it as a basic information.