A proximity voice chat solution for Unity, compatible with Netcode for GameObjects.
This package supports voice playback through FMOD Studio as a programmer instrument event, or directly through the core FMOD Engine API instead. Playback through FMOD Studio is highly recommended, as it enables audio auditioning and the ability to efficiently design and alter voice audio effects.
If you do not plan to use FMOD Studio for voice playback, skip to Step #2, and for those already familiar with how to setup FMOD in Unity, skip straight to Step #3.
- Download and install FMOD Studio
- Run FMOD Studio and create a
New Project
(or use an existing one) - Save this project anywhere on your machine
- Add the FMOD for Unity package to your assets from the Unity Asset Store
- In Unity, open
Window -> Package Manager
- Select
My Assets
in thePackages:
dropdown - Locate FMOD for Unity and click
Import
to import it into your project - Follow the FMOD Setup Wizard's instructions, linking the FMOD Studio project you created if desired
- In Unity, open
Window -> Package Manager
. - Click the
+
button - Select
Add package from git URL
- Paste
git@github.com:matthiasbroske/ProximityChat-UnityPackage.git
to install the latest version- If you want to access a particular release or branch, you can append
#<tag or branch>
at the end, e.g.git@github.com:matthiasbroske/ProximityChat-UnityPackage.git#main
- If you want to access a particular release or branch, you can append
If you would like to play voice audio through FMOD Studio, follow the instructions below.
- Open the FMOD Studio project you linked to your Unity project
- In the
Events
tab, right click and selectEvent Defaults > 3D Timeline
to create a spatialized event through which we will play voice audio, and name it something like "Voice Chat"
- Assign this event to a bank of your chosing by right clicking on it and selecting
Assign to Bank > Browse
and choosing a bank
- Right click inside the track named
Audio 1
and selectAdd Programmer Instrument
- Resize the instrument such that it is exactly 1 second long, starting from 0:00
- Right click in the
Logic Tracks
region and selectNew Loop Region
, resizing it to be exactly the same size as the programmer instrument
- Click on the programmer instrument, enabling
Async
andLoop Instrument
with an infinitePlay Count
- This event is where our voice audio will be played, so feel free to add additional audio effects or tweak the spatialization settings of the master track here as desired
- Save and build the FMOD Studio project before returning to Unity
- In Unity, locate the
Voice Networker (Studio)
Prefab in theRuntime/Prefabs
folder of the ProximityChat package - Drag and drop that prefab onto your networked Player Prefab, ideally attached to the camera at eye/ear-level
- Locate the
StudioVoiceEmitter
component of that prefab, and fill in theVoice Event Reference
field by clicking the magnifying glass and selecting the "Voice Chat" event you created in FMOD Studio - See How to Use for instructions on how to start/stop voice recording
If you would like to play voice audio directly, without using FMOD Studio, follow the instructions below.
- Locate the
Voice Networker (Core)
Prefab in theRuntime/Prefabs
folder of the ProximityChat package - Drag and drop this prefab onto your networked Player Prefab, ideally attached to the camera at eye/ear-level
- See How to Use for instructions on how to start/stop recording voice
- Start recording and transmitting audio over the network (perhaps when a push-to-talk key is pressed) by calling the
StartRecording()
method of theVoiceNetworker
component - Stop recording by calling the
StopRecording()
method of theVoiceNetworker
component
To determine whether or not audio is being sent and received over the network without having to boot up multiple instances of
your project, simply toggle on Playback Own Voice ☑
on the VoiceNetworker
component of the Voice Networker prefab you attached
to your player.
Follow the above setup and usage instructions to use immediatly in a Unity project with Netcode for GameObjects.
In theory this package is compatible with almost any networking solution for Unity, as all it needs to function is the ability
to send and receive bytes of encoded audio data over the network.
Take a look at VoiceNetworker
to get a feel for how this might be achieved with your networking setup.