Voice chat for unity networking?

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

5 Likes

Im also very interested in this : )

Check this out, it’s from exitgames: Unity Asset Store - The Best Assets for Game Making
And here is one from fholm: https://github.com/fholm/unityassets/tree/master/VoiceChat

The last one from fholm, worked for me very well

1 Like

First one is not Unet, he other one looks interesting though.

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

Would be awesome if you could share your findings here : )

Allright so if you want to follow along;

  • Download the VoiceChat project
  • Open it in Unity
  • Open the “Networking [HLAPI]” scene
  • Press Play
  • Select “LAN Host(H)”
  • Select your mic
  • Notice the error in the console

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.

Did you try looking for existing solutions like TeamSpeak ?? Far as I can remember they had Unity integration package.

I ve managed to get daiko forge’s voip to work with UNET.

http://daikonforge.com/forums/threads/unet-and-dfvoice.2462/

I’m trying to get the voice chat to work with the asset from fholm.
Did you have any progress with the networkid of the host?

I’m using DFvoice and UNET, and managed finally to work.

I encountered the same problem: “NetworkId not set”. How to solve it?

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.

6 Likes

yes we will add voip support. But I do not have any ETA for this… Sorry about

11 Likes

Wow. Big thanks for your help.

2 Likes

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.

that’s tied to Photon Networking. Not really an option