Zum Hauptinhalt springen
Version: bleeding-edge 🩸

Voice over IP (VOIP)

How VOIP works in nanos world and how to use it.

nanos world provides a built-in Voice over IP (VOIP) system using Steam's native implementation that allows players to communicate with each other in-game through voice. The VOIP system is highly customizable and can be configured to use local/proximity chat, global channels, or both.

VOIP Audio Types​

The VOIP system is based on two main types: local/proximity and global.

Local/Proximity​

Local VOIP uses a 3D spatialized audio to output the Player's voice. Usually this is attached to the possessing Player's Character and simulates a realistic audio environment where players can only hear each other if they are close by.

You can enable or disable local chat for a player using Player:SetVOIPLocalSetting(). The volume of the local chat can be adjusted with Player:SetVOIPLocalVolume(), and how far the voice can be heard with Player:SetVOIPLocalMaxDistance().

Global​

Global VOIP allows players to communicate with each other regardless of their location in the game world. There are 63 global channels available (1-63). Players can be configured to listen or speak on specific channels.

You can configure a player's settings for a specific global channel using Player:SetVOIPGlobalChannelSetting() or for all channels at once with Player:SetVOIPGlobalAllChannelsSetting(). Also the volume of the global chat can be adjusted with Player:SetVOIPGlobalVolume().

You can check in which channels a player is listening or speaking with Player:GetVOIPListeningChannels() and Player:GetVOIPSpeakingChannels().

Server/Index.lua
-- Creates a "team radio": players of each team speak and listen only in their team channel
function SetPlayerTeamRadio(player, team)
-- Stops listening and speaking in all global channels
player:SetVOIPGlobalAllChannelsSetting(VOIPSetting.None)

-- Speaks and listens in the team channel (team 1 uses channel 1, and so on)
player:SetVOIPGlobalChannelSetting(team, VOIPSetting.Both)
end

High/Low Pass filters​

In the Global Channels, it is possible to set filters on the Global audio with the methods Player:SetVOIPGlobalHighPassFilter() and Player:SetVOIPGlobalLowPassFilter().

We can simulate a Radio Effect by setting a High Pass filter like player:SetVOIPGlobalHighPassFilter(8000).

note

High/Low Pass filters are only available in the Global Channels.

VOIP Settings​

The VOIP settings for both local and global channels are configured using the VOIPSetting enum. It is possible to define if the player will just listen, speak or both, on the local channel and on each global channel!

Knowing Who is Talking​

The VOIP event is triggered when a player starts or stops talking, which is useful to display a "talking" indicator in your UI:

Client/Index.lua
Player.Subscribe("VOIP", function(player, is_talking)
Console.Log("%s is %s", player:GetName(), is_talking and "talking" or "silent")
end)

Muting​

There are two independent ways a player can be muted.

Muted by scripts: it is possible to mute a certain player using the Player:SetVOIPMuted() method. If this is called on Server side, the Player will be muted for everyone (and their game stops sending their voice), but it can also be called on client side for a local mute.

Muted by the player: players can mute their own microphone with the Mute button in the escape menu, or by pressing the VOIP key while using Open Mic. This mute belongs to the player: scripts can't change it, but can read it with Client.IsVOIPSelfMuted() and listen to the VOIPSelfMuteChange event, for example to show a muted icon in your UI:

Client/Index.lua
Client.Subscribe("VOIPSelfMuteChange", function(is_muted)
MyHUD:CallEvent("SetMicMuted", is_muted)
end)

The player's own mute is kept while the game is open, even when switching servers, but it is not saved.

Push to Talk and Open Mic​

Each player chooses in the Audio settings how their microphone works:

  • Push to Talk (default): the voice is only sent while the player holds the VOIP key.
  • Open Mic: the voice is always sent, unless the player muted themselves. In this mode, pressing the VOIP key toggles the player's own mute.

This is a player preference and can't be changed by scripts, but you can read it from Client.GetSettings() with the VoicePushToTalk key, for example to show the right hint in your UI.

Configuring Microphone​

As we use Steam implementation, you can configure your microphone in the Steam's settings, which can be accessed through the Steam client or Shift+Tab Overlay. This allows you to adjust your microphone volume, test your microphone, and set other audio preferences.

Steam voice settings