Godot Version
4.2
Question
I’m trying to add voice chat to my online game after following a super simple tutorial.
The problem is that the voice chat doesn’t seem to be working.
Here is the tutorial I followed (if needed): Godot | voice chat tutorial (youtube.com)
I have a bus called Record that is muted and it takes Audio. My project is also set to listen to audio.
Code:
var effect
var recording
func _ready():
new_deceiver = false
time_out = time_out_set
jump_time = jump_time_set
chat_box.play("default")
if is_multiplayer_authority():
$TestName.text = Network.user_name
$UI.visible = true
$CamPos/Camera2D.zoom = Vector2(Data.fov, Data.fov)
looks.play("idle")
if Network.hat == 0:
print("Hat error")
Network.hat = 1
dec_speed = false
var idx = AudioServer.get_bus_index("Record")
effect = AudioServer.get_bus_effect(idx, 0)
effect.set_recording_active(true)
#effect.
#There is other stuff here blah blah blah. ---
func _on_send_recording_timer_timeout():
print("Send Done")
recording = effect.get_recording()
effect.set_recording_active(false)
rpc("send_rec_data", recording.data)
effect.set_recording_active(true)
@rpc() func send_rec_data(rec_data):
var sample = AudioStreamWAV.new()
sample.data = rec_data
sample.format = AudioStreamWAV.FORMAT_16_BITS
sample.mix_rate = AudioServer.get_mix_rate()*2
$Audio/AudioStreamPlayer.stream = sample
$Audio/AudioStreamPlayer.play()
Thank you.