Voice Chat: CreateVoiceCapture() returning Null

I’m trying to implement voice chat on Windows and the following code (copied from TestVoice.cpp) results in VoiceCapture, VoiceEncoder and VoiceDecoder being Null, making the IsValid call return false:

#include "OnlineSubsystemUtils.h"
#include "VoiceController.h"
#include "Engine.h"
#include "Voice.h"

...

bool AVoiceController::Init()
{
	UE_LOG(LogTemp, Warning, TEXT("VoiceController Init"));

	VoiceCapture = FVoiceModule::Get().CreateVoiceCapture();
	VoiceEncoder = FVoiceModule::Get().CreateVoiceEncoder();
	VoiceDecoder = FVoiceModule::Get().CreateVoiceDecoder();

	if (VoiceCapture.IsValid())
	{
		UE_LOG(LogTemp, Warning, TEXT("VoiceController Init is valid"));
		VoiceCapture->Start();
	}

	return true;
}

...

Does anybody have any ideas why this may be happening?

Edit: I’m calling Init on event begin play.

Solved the issue. I had forgotten to add the following config lines as specified in this post.

DefaultEngine.ini

[Voice] 
bEnabled=true
 
[OnlineSubsystem] 
bHasVoiceEnabled=true

DefaultGame.ini

[/Script/Engine.GameSession]
bRequiresPushToTalk=false
1 Like

you are right