Skip to content

matthiasbroske/ProximityChat-UnityPackage

Repository files navigation

ProximityChat

About

A proximity voice chat solution for Unity, compatible with Netcode for GameObjects.

  • Uses FMOD for audio recording and playback
  • Uses Opus for audio encoding and decoding via Concentus

Installation

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.

Step #1: Install FMOD Studio

  1. Download and install FMOD Studio
  2. Run FMOD Studio and create a New Project (or use an existing one)
  3. Save this project anywhere on your machine

Step #2: Install FMOD for Unity

  1. Add the FMOD for Unity package to your assets from the Unity Asset Store
  2. In Unity, open Window -> Package Manager
  3. Select My Assets in the Packages: dropdown
  4. Locate FMOD for Unity and click Import to import it into your project
  5. Follow the FMOD Setup Wizard's instructions, linking the FMOD Studio project you created if desired

Step #3: Install ProximityChat

  1. In Unity, open Window -> Package Manager.
  2. Click the + button
  3. Select Add package from git URL
  4. 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

Setup

Option #1: FMOD Studio Setup

If you would like to play voice audio through FMOD Studio, follow the instructions below.

  1. Open the FMOD Studio project you linked to your Unity project
  2. In the Events tab, right click and select Event Defaults > 3D Timeline to create a spatialized event through which we will play voice audio, and name it something like "Voice Chat"

image

  1. Assign this event to a bank of your chosing by right clicking on it and selecting Assign to Bank > Browse and choosing a bank

image

  1. Right click inside the track named Audio 1 and select Add Programmer Instrument

image

  1. Resize the instrument such that it is exactly 1 second long, starting from 0:00

image

  1. Right click in the Logic Tracks region and select New Loop Region, resizing it to be exactly the same size as the programmer instrument

image

  1. Click on the programmer instrument, enabling Async and Loop Instrument with an infinite Play Count

image

  1. 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

image

  1. Save and build the FMOD Studio project before returning to Unity

image

  1. In Unity, locate the Voice Networker (Studio) Prefab in the Runtime/Prefabs folder of the ProximityChat package
  2. Drag and drop that prefab onto your networked Player Prefab, ideally attached to the camera at eye/ear-level
  3. Locate the StudioVoiceEmitter component of that prefab, and fill in the Voice Event Reference field by clicking the magnifying glass and selecting the "Voice Chat" event you created in FMOD Studio
  4. See How to Use for instructions on how to start/stop voice recording

Option #2: FMOD Engine Setup

If you would like to play voice audio directly, without using FMOD Studio, follow the instructions below.

  1. Locate the Voice Networker (Core) Prefab in the Runtime/Prefabs folder of the ProximityChat package
  2. Drag and drop this prefab onto your networked Player Prefab, ideally attached to the camera at eye/ear-level
  3. See How to Use for instructions on how to start/stop recording voice

How to Use

Start/Stop Recording

  • Start recording and transmitting audio over the network (perhaps when a push-to-talk key is pressed) by calling the StartRecording() method of the VoiceNetworker component
  • Stop recording by calling the StopRecording() method of the VoiceNetworker component

Debug

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.

Networking

Netcode for GameObjects

Follow the above setup and usage instructions to use immediatly in a Unity project with Netcode for GameObjects.

Other Networking Frameworks

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.

About

Proximity voice chat for Unity using FMOD, compatible with Netcode for GameObjects

Topics

Resources

License

Stars

Watchers

Forks

Languages