Get Enhanced Input Local Player Subsystem in C++

Hi!

I’m trying to transcribe VRPawn’s Blueprint to C++ (from VR Template), on BeginPlay()
but im stuck at this point (image included)

I cant find a way to get Enhanced Input Local Player Subsystem from Player Controller, it looks like there is no way to get it at least looking at documents:

APlayerController | Unreal Engine 5.2 Documentation

How can i get it ?

Thanks.

#include "Engine/LocalPlayer.h"
#include "EnhancedInputComponent.h"
#include "EnhancedInputSubsystems.h"

void Class::BeginPlay()
{
	Super::BeginPlay();

	if (APlayerController* PlayerController = Cast<APlayerController>(Controller))
	{
		if (UEnhancedInputLocalPlayerSubsystem* Subsystem = ULocalPlayer::GetSubsystem<UEnhancedInputLocalPlayerSubsystem>(PlayerController->GetLocalPlayer()))
		{
			Subsystem->AddMappingContext(DefaultMappingContext, 0);
		}
	}
}

Add EnhancedInput to your Project.Build.cs file:

PublicDependencyModuleNames.AddRange(new[]
{
	...,
	"EnhancedInput"
});
3 Likes

Thanks for the fast reply…

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.