Voice chat in Unity help needed!
The whole answer can be found below.
Try Our
Documentation
Please check if you can find an answer in our extensive documentation on Voice.
Join Us
on Discord
Meet and talk to our staff and the entire Photon-Community via Discord.
Read More on
Stack Overflow
Find more information on Stack Overflow (for Circle members only).
Voice chat in Unity help needed!
3amt87
2022-01-14 15:11:07
I post this here as well, because I have no Idea which of the caregories it should go into.
I'm trieing for days to make use of the photon voice chat app. However, it's not working so far. The setup should be ok(?) I made an App and connected with the PUN Wizard. I have the App Id for PUN and the App ID for Voice connected, Checked "User Name Server", "Port 0", "Protocol: UPD", "Protocol Fallback", "Run in Background". Pretty much the default settings with my App Id. Is there more I have to setup?
First of all. I have a game already, I do not want to use anything from photon other than the voice chat!
My player setup is identical to the "Prefab Setup (PhotonVoiceView)" here:
https://doc.photonengine.com/en-us/voice/v2/getting-started/voice-for-pun#suggested_workflow
In my project the player gets created on gamestart like:
player = Instantiate(playerPrefab).transform;
When I run the game photon is not working, throwing only one error, no recorder initialized:
NullReferenceException: Object reference not set to an instance of an object
Photon.Voice.Unity.Recorder.CreateLocalVoiceAudioAndSource () (at Assets/Photon/PhotonVoice/Code/Recorder.cs:1778)
So I tried to initialize the recorder, but the documentation is very spare about it.
PhotonVoiceNetwork.InitRecorder(Recorder)
Recorder.Init(VoiceConnection)
and both didn't help in any way of course.
Searching the forums I found an other way to instanziate, like:
player = PhotonNetwork.Instantiate(this.playerPrefab.name)
I was wondering why this functions need a string and how it is suppost to work. Anyways I changed it to:
player = PhotonNetwork.Instantiate(playerPrefab.name, new Vector3(0f, 0f, 0f), Quaternion.identity, 0).transform;
Didn't work and after more research i found that the prefabs should be in a resource folder, so I moved them, but it did not help. On more search I found this page: https://doc.photonengine.com/zh-cn/pun/current/demos-and-tutorials/pun-basics-tutorial/player-instantiation#instantiating_the_player
Won't work for me either. I can not easily set it up like this, because I handle the player actions in my own script already. I tried to make the instanziation in my script but it dosn't woirk (of course) because the photon engine isn't ready.
So I was really wondering what else I could do. Damn, this is a million times more complicated than advertised. Any help would be appriciated. I have no ideas anymore, other than trying out different frameworks.
Comments
Hi @3amt87,
Thank you for choosing Photon and I apologize for the delay and for the issues you ran into!
First of all. I have a game already, I do not want to use anything from photon other than the voice chat!
OK. But did you try the demos in a fresh empty project first to get familiar with things before you start importing it into your own project?
Also I want to get this right, you want to use Photon Voice WITHOUT PUN or any other Photon product, is that it?
When I run the game photon is not working, throwing only one error, no recorder initialized:
NullReferenceException: Object reference not set to an instance of an object
Photon.Voice.Unity.Recorder.CreateLocalVoiceAudioAndSource () (at Assets/Photon/PhotonVoice/Code/Recorder.cs:1778)
Which Photon Voice version did you try? latest? I'm interested to know how to reproduce this with latest Photon Voice.
So I tried to initialize the recorder, but the documentation is very spare about it.
PhotonVoiceNetwork.InitRecorder(Recorder)
Recorder.Init(VoiceConnection)
and both didn't help in any way of course.
Searching the forums I found an other way to instanziate, like:
player = PhotonNetwork.Instantiate(this.playerPrefab.name)
I was wondering why this functions need a string and how it is suppost to work. Anyways I changed it to:
player = PhotonNetwork.Instantiate(playerPrefab.name, new Vector3(0f, 0f, 0f), Quaternion.identity, 0).transform;
Didn't work and after more research i found that the prefabs should be in a resource folder, so I moved them, but it did not help. On more search I found this page: https://doc.photonengine.com/zh-cn/pun/current/demos-and-tutorials/pun-basics-tutorial/player-instantiation#instantiating_the_playe
r
If you don't use PUN then you don't need any of this.
here are the instructions to remove PUN from Photon Voice
here are the instructions to remove Photon Chat from Photon Voice
here are the instructions to use Photon Voice without PUN
Back to top