Search Unity

  1. The Unity Pro & Visual Studio Professional Bundle gives you the tools you need to develop faster & collaborate more efficiently. Learn more.
    Dismiss Notice
  2. Improved Prefab workflow (includes Nested Prefabs!), 2D isometric Tilemap and more! Get the 2018.3 Beta now.
    Dismiss Notice
  3. Want more efficiency in your development work? Sign up to receive weekly tech and creative know-how from Unity experts.
    Dismiss Notice
  4. Participate with students all over the world and build projects to teach people. Join now!
    Dismiss Notice
  5. Build games and experiences that can load instantly and without install. Explore the Project Tiny Preview today!
    Dismiss Notice
  6. Improve your Unity skills with a certified instructor in a private, interactive classroom. Watch the overview now.
    Dismiss Notice
  7. Want to see the most recent patch releases? Take a peek at the patch release page.
    Dismiss Notice

Unity Multiplayer Voice chat for unity networking?

Discussion in 'Connected Games' started by PhilSA, Apr 26, 2016.

  1. PhilSA

    PhilSA

    Joined:
    Jul 11, 2013
    Posts:
    906
    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
     
  2. virror

    virror

    Joined:
    Feb 3, 2012
    Posts:
    2,960
    Im also very interested in this : )
     
  3. TiToMoskito

    TiToMoskito

    Joined:
    Jun 10, 2015
    Posts:
    35
    zhangjin_ likes this.
  4. virror

    virror

    Joined:
    Feb 3, 2012
    Posts:
    2,960
    First one is not Unet, he other one looks interesting though.
     
  5. PhilSA

    PhilSA

    Joined:
    Jul 11, 2013
    Posts:
    906
  6. virror

    virror

    Joined:
    Feb 3, 2012
    Posts:
    2,960
    Would be awesome if you could share your findings here : )
     
  7. PhilSA

    PhilSA

    Joined:
    Jul 11, 2013
    Posts:
    906
    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
     
  8. virror

    virror

    Joined:
    Feb 3, 2012
    Posts:
    2,960
    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 : )
     
  9. dhuang

    dhuang

    Joined:
    Jan 5, 2016
    Posts:
    38
    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.
     
  10. Severos

    Severos

    Joined:
    Oct 2, 2015
    Posts:
    161
    Did you try looking for existing solutions like TeamSpeak ?? Far as I can remember they had Unity integration package.
     
  11. akuno

    akuno

    Joined:
    Dec 14, 2015
    Posts:
    33
  12. flammen_schwert

    flammen_schwert

    Joined:
    Feb 18, 2015
    Posts:
    2
    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?
     
  13. wobes

    wobes

    Joined:
    Mar 9, 2013
    Posts:
    494
    I'm using DFvoice and UNET, and managed finally to work.
     
    Last edited: Nov 30, 2016
  14. Pulas

    Pulas

    Joined:
    Feb 26, 2014
    Posts:
    9
    I encountered the same problem: "NetworkId not set". How to solve it?
     
  15. RaymondYan

    RaymondYan

    Joined:
    Dec 6, 2016
    Posts:
    1
    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
    Code (CSharp):
    1.         public bool StartRecording()
    2.         {
    3.             /*
    4.             if (NetworkId == 0 && !VoiceChatSettings.Instance.LocalDebug)
    5.             {
    6.                 Debug.LogError("NetworkId is not set");
    7.                 return false;
    8.             }*/
    • And Then modified the code in VoiceChat\Assets\VoiceChat\Scripts\Networking\VoiceChatNetworkProxy.cs
    From:
    Code (CSharp):
    1. public bool isMine { get { return networkId != 0 && networkId == localProxyId; } }
    To:
    Code (CSharp):
    1. public bool isMine { get { return networkId == localProxyId; } }
    • In VoiceChatPlayer.cs, modified from:
    Code (CSharp):
    1.  
    2. public void OnNewSample(VoiceChatPacket newPacket)
    3.         {
    4.             // Set last time we got something
    5.             lastRecvTime = Time.time;
    6.  
    7.             packetsToPlay.Add(newPacket.PacketId, newPacket);
    8.  
    9.             if (packetsToPlay.Count < 10)
    10.             {
    11.                 return;
    12.             }
    13.  
    To:
    Code (CSharp):
    1.         public void OnNewSample(VoiceChatPacket newPacket)
    2.         {
    3.             // Set last time we got something
    4.             lastRecvTime = Time.time;
    5.             // Add this new line;
    6.             if ( packetsToPlay.ContainsKey( newPacket.PacketId ) ) return;
    7.  
    8.             packetsToPlay.Add(newPacket.PacketId, newPacket);
    9.  
    10.             if (packetsToPlay.Count < 10)
    11.             {
    12.                 return;
    13.             }
    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.
     
    Last edited: Dec 6, 2016
  16. aabramychev

    aabramychev

    Unity Technologies

    Joined:
    Jul 17, 2012
    Posts:
    555
    yes we will add voip support. But I do not have any ETA for this.. Sorry about
     
    Cippman, TwoTen, LostPanda and 8 others like this.
  17. Pulas

    Pulas

    Joined:
    Feb 26, 2014
    Posts:
    9
    Wow. Big thanks for your help.
     
    sun_stealer and MendyBerger like this.
  18. flammen_schwert

    flammen_schwert

    Joined:
    Feb 18, 2015
    Posts:
    2
    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.
     
  19. Traxxy

    Traxxy

    Joined:
    Mar 21, 2016
    Posts:
    18
  20. PhilSA

    PhilSA

    Joined:
    Jul 11, 2013
    Posts:
    906
  21. Eiseno

    Eiseno

    Joined:
    Nov 1, 2015
    Posts:
    71
    thank you :)
     
  22. kitten_of_death

    kitten_of_death

    Joined:
    Feb 27, 2015
    Posts:
    4
    I can hear the voice as a client, but why the networkId is 0 ?? Did anyone get it fully working with client-server both ways?
     
  23. zhangjin_

    zhangjin_

    Joined:
    Aug 6, 2015
    Posts:
    1
    It can work by running one instance as a host and another instance as client, I think what RaymondYan says here
    means that the client which runs as a host will have its networkId as 0 because according to UNET doc here, the host side is basically a client that works also as a server. Please correct me if I am wrong here.
     
  24. pavan123

    pavan123

    Joined:
    Nov 5, 2016
    Posts:
    4
    Hi I have tried the second link https://github.com/fholm/unityassets/tree/master/VoiceChat provided by TiToMoskito. i have downloaded that zip file and opened voice chat project in my unity application and did the required modifications,now it is working fine for me,able to get voice chat between server and client through microphone but one problem annoys me a lot that is connection between server and client through microphone is no longer available means connection keeps break down in less than a minute.could anyone help me to figure out this problem.
     
    Last edited: Jan 28, 2017
  25. vicator

    vicator

    Joined:
    Oct 12, 2014
    Posts:
    25
    Testing the VoiceChat by fholm. I am experiencing a delay over time causing the playback of the actual recorded chat to lag behind more and more in time of clients.

    Anyone got any hints of where to start looking to solve this? Is it a case of discarding packets on the listening clients if their timestamp in relation to the server is way off?
     
  26. TobiasW

    TobiasW

    Joined:
    Jun 18, 2011
    Posts:
    66
    I realize that PhilSA probably isn't interested anymore after all this time, but since other people might be...

    We are using UNET and tried every package we could find. The only ones that worked with low latency and good voice quality were:
    • TeamSpeak 3 SDK
      • Pros: Low latency. Good voice quality. Makes its own connection (doesn't use UNET), but doesn't need a big network solution besides UNET. Super easy to setup and use.
      • Cons: Doesn't use AudioSources to play back voice audio, which makes using plugins for spatialization (e.g. for VR) impossible. Minor bugs and pretty much non-existing support. Needs an additional TeamSpeak server.
    • Photon Voice
      • Pros: Low latency. Good voice quality. Uses AudioSources to play back voice audio.
      • Cons: Needs an additional Photon connection (and server) on top of our UNET connection. Is a bit harder to set up than TeamSpeak.
     
    chgeorgiadis likes this.
  27. ludos

    ludos

    Joined:
    Nov 14, 2011
    Posts:
    53
    sun_stealer likes this.
  28. Nyarlathothep

    Nyarlathothep

    Joined:
    Jun 13, 2013
    Posts:
    170
    I've recently released Dissonance Voice Chat on the asset store. Dissonance is designed to work with any networking system (out of the box it works with Unet, Photon and Forge - you'll need to write a little bit of glue code if you're using another network system).
     
    digiross, ilmario and TwoTen like this.
  29. PartyBoat

    PartyBoat

    Joined:
    Oct 21, 2012
    Posts:
    60
    YEEEEEEEEEEEEEEESSSSS!!! I have been waiting forever for something like Dissonance to come out! Glad to see it finally released and that so far it's getting great reviews. Instant buy for me!

    Also, OP the answer to your question is most likely buy Dissonance, it's really the only asset on the market that does VOIP besides Photon Voice which locks you into paying Photon per concurrent user (yuck).
     
    Nyarlathothep likes this.
  30. TobiasW

    TobiasW

    Joined:
    Jun 18, 2011
    Posts:
    66
    Does Dissonance use AudioSources to play back the audio?

    edit: Disregard that, I found the video which shows that it does. Awesome - I'll probably have a go with it if my client agrees!

    (By the way, you might want to add the video to the asset description and/or the example thumbnail section.)
     
    Last edited: Mar 8, 2017
  31. Nyarlathothep

    Nyarlathothep

    Joined:
    Jun 13, 2013
    Posts:
    170
    Good idea, I'll have a look at doing that with the next release (planned for early next week).

    Just to sum up a few of the things Dissonance does:

    - Playback through AudioSource. This means various mixer effects should work in the same way as any other audio source in your games. We've got several people successfully using the Oculus Spatializer with Dissonance for example.
    - Opus codec with Speex preprocessing. Everyone uses Opus for encoding, it's a fantastic codec. In Dissonance we're also running the voice through the speex preprocessor to further improve the audio quality (noise removal, automatic gain control).
    - As much work as possible is done off the main thread in Dissonance which means we're not limited by a low framerate introducing extra latency into the speech. It also means that Dissonance should never impact your frame rate.
    - There's a low level channels API which allows you to explicitly control who is talking and who's listening. There's a load of possibilities for setting up complex channel hierarchies (e.g. raid members can listen but get muted as soon as the raid leader talks).
     
  32. wobes

    wobes

    Joined:
    Mar 9, 2013
    Posts:
    494
    Hi there, does Dissonance supports Unet HLAPI? Thanks
     
    Nyarlathothep and TwoTen like this.
  33. Nyarlathothep

    Nyarlathothep

    Joined:
    Jun 13, 2013
    Posts:
    170
    Last edited: Aug 30, 2017
    wobes likes this.
  34. wobes

    wobes

    Joined:
    Mar 9, 2013
    Posts:
    494
    Thank you so much. ;)
     
    Nyarlathothep likes this.
  35. TwoTen

    TwoTen

    Joined:
    May 25, 2016
    Posts:
    1,011
    Has anyone had any success with the Steamworks Voicechat?
    I'm concidering giving it a try.
     
  36. MendyBerger

    MendyBerger

    Joined:
    Sep 17, 2017
    Posts:
    2
    Last edited: Oct 17, 2017
    wobes likes this.
  37. MendyBerger

    MendyBerger

    Joined:
    Sep 17, 2017
    Posts:
    2

    I also really appreciate it!
     
  38. chgeorgiadis

    chgeorgiadis

    Joined:
    Jan 30, 2018
    Posts:
    7

    @TobiasW i would like to use voice chat in a multiplayer VR game. Do you have any update in these suggestions? Thank you!
     
  39. TobiasW

    TobiasW

    Joined:
    Jun 18, 2011
    Posts:
    66
    Hey @chgeorgiadis! Sorry, it's been forever since I worked on that. We also tried Dissonance, but I don't remember which one we picked at the end.
     
    chgeorgiadis and Nyarlathothep like this.