Voice
constVoice:object
Defined in: client/api.d.ts:2737
Local player’s proximity voice chat settings: on/off, playback volume, hearing range and the push-to-talk binding.
Type Declaration
Section titled “Type Declaration”getHearingRange()
Section titled “getHearingRange()”getHearingRange():
number
Reads the local hearing-range limit.
Returns
Section titled “Returns”number
Radius in world units, or 0 when the server’s range applies unreduced.
getPushToTalkKey()
Section titled “getPushToTalkKey()”getPushToTalkKey():
string
Reads the push-to-talk binding.
Returns
Section titled “Returns”string
Canonical key name, e.g. “v”.
getRange()
Section titled “getRange()”getRange():
number
Reads the server’s proximity range for talkers with no override of their own.
Returns
Section titled “Returns”number
Radius in world units.
getVolume()
Section titled “getVolume()”getVolume():
number
Reads the voice playback volume.
Returns
Section titled “Returns”number
Current gain, where 1 is unattenuated.
hasMicrophone()
Section titled “hasMicrophone()”hasMicrophone():
boolean
Checks whether a capture device opened for this session.
Returns
Section titled “Returns”boolean
False when the player has no working microphone, i.e. they are listen-only.
isEnabled()
Section titled “isEnabled()”isEnabled():
boolean
Checks whether voice chat is enabled for this player.
Returns
Section titled “Returns”boolean
True unless the player turned voice chat off.
isTalking()
Section titled “isTalking()”isTalking():
boolean
Checks whether the local player is transmitting right now.
Returns
Section titled “Returns”boolean
True while push-to-talk is held and the microphone is producing audio.
setEnabled()
Section titled “setEnabled()”setEnabled(
enabled):void
Turns voice chat on or off. Off closes the microphone and playback devices and tells the server to stop relaying voice to this client.
Parameters
Section titled “Parameters”enabled
Section titled “enabled”boolean
Whether voice chat runs at all for this player.
Returns
Section titled “Returns”void
setHearingRange()
Section titled “setHearingRange()”setHearingRange(
range):void
Narrows how far this player hears others. Can only reduce the server’s range, since a talker beyond it is never relayed.
Parameters
Section titled “Parameters”number
Audibility radius in world units; 0 removes the local limit.
Returns
Section titled “Returns”void
setPushToTalkKey()
Section titled “setPushToTalkKey()”setPushToTalkKey(
key):void
Rebinds push-to-talk. Unknown key names throw.
Parameters
Section titled “Parameters”string
Case-insensitive key name, using the same names as Key.bind.
Returns
Section titled “Returns”void
setVolume()
Section titled “setVolume()”setVolume(
volume):void
Sets the playback volume of incoming voice. Applies to the built-in mixer only.
Parameters
Section titled “Parameters”volume
Section titled “volume”number
Playback gain, where 1 is unattenuated. Clamped to 0..4.
Returns
Section titled “Returns”void
