I’m looking for a voice chat solution compatible with Unity’s new networking system, but haven’t found anything functionnal/trustworthy yet. All I could find were very badly-reviewed asset store packages that haven’t been updated in over a year, and a project on github that throws errors as soon as it detects a mic. Can anyone point me to something?
Also, is Unity planning on adding this as an official feature at some point? Seems like there is a very clear need for a solid solution in that department
I’ve tried the second one, but it keeps giving me a “Network Id not set” error whenever I select a mic. I’ve done some debugging but haven’t been able to figure out what was going on yet. I guess I’ll keep debugging
Now what I’ve been able to find out so far is that it seems like this “Network Id not set” error only happens when the host of the game tries to select a device (so presumably, it happens if the server tries to use voice recording). I was able to make things work by following these steps:
Make a build with the “Networking [HLAPI]” scene
Start one instance as host, but don’t select a mic. Just leave it there
Start two client instances, and select your mics
Try to record on one of those client instances (hold ‘P’ to record), and you’ll hear your voice on the other one
Basically all that’s left to figure out for me is why this VoiceChat system doesn’t correctly assign a net ID to the host
Strange, so it works from client to the others, but not from the host. I wonder how the bandwidth is for this solution as well, would be nice if it was not super heavy.
Thank for looking into this : )
I had the same error, so I went through these steps but was not able to get the two instances of the build to transmit voice. I was able to hear myself when I check the local Debug mode, but cannot do it over the network at all. Has anyone gotten further on this issue? thanks in advance.
In case anyone is still facing the “NetworkId not set” problem for the VoiceChat, here is the solution:
Mark the following code in VoiceChat\Assets\VoiceChat\Scripts\VoiceChatRecorder.cs
public bool StartRecording()
{
/*
if (NetworkId == 0 && !VoiceChatSettings.Instance.LocalDebug)
{
Debug.LogError("NetworkId is not set");
return false;
}*/
And Then modified the code in VoiceChat\Assets\VoiceChat\Scripts\Networking\VoiceChatNetworkProxy.cs
From:
public bool isMine { get { return networkId != 0 && networkId == localProxyId; } }
To:
public bool isMine { get { return networkId == localProxyId; } }
In VoiceChatPlayer.cs, modified from:
public void OnNewSample(VoiceChatPacket newPacket)
{
// Set last time we got something
lastRecvTime = Time.time;
packetsToPlay.Add(newPacket.PacketId, newPacket);
if (packetsToPlay.Count < 10)
{
return;
}
To:
public void OnNewSample(VoiceChatPacket newPacket)
{
// Set last time we got something
lastRecvTime = Time.time;
// Add this new line;
if ( packetsToPlay.ContainsKey( newPacket.PacketId ) ) return;
packetsToPlay.Add(newPacket.PacketId, newPacket);
if (packetsToPlay.Count < 10)
{
return;
}
I think the purpose of the author is to check if we have connect to the network, if not the networkId would be 0. However in Unity the server side client’s network connection id is also 0.
Thank you!
I’ve not worked on my project for the last few weeks… I figured out your remarks on the code back than except for the ones in the VoiceChatPlayer.