Character Selection - Lyra Starter Game

Try this

LyraSettingsLocal.h

//  Character selection
public:
	UFUNCTION(BlueprintCallable)
	int32 GetUserCharacter();
	UFUNCTION(BlueprintCallable)
	void SetUserCharacter(int32 NewUserCharacter);

private: 
	UPROPERTY(Config)
	int32 UserCharacter;

LyraSettingsLocal.cpp

int32 ULyraSettingsLocal::GetUserCharacter()
{
	return UserCharacter;
}

void ULyraSettingsLocal::SetUserCharacter(int32 InUserCharacter)
{
	UserCharacter = InUserCharacter;
}

LyraGameInstance.h

#include "Settings/LyraSettingsLocal.h"

public:
        ULyraSettingsLocal* UserSettings;

	UFUNCTION(BlueprintCallable)
	ULyraSettingsLocal * GetUserSettings();

LyraGameInstance.cpp

#include "Settings/LyraSettingsLocal.h"

void ULyraGameInstance::Init()
{
	Super::Init();
	UserSettings = ULyraSettingsLocal::Get();
}

ULyraSettingsLocal* ULyraGameInstance::GetUserSettings()
{
	return UserSettings;
}

In the blueprint use “Get Game Instance” cast to LyraGameInstance then “Get User Settings” then “Get/Set User Character”

I also used nodes “Is Locally controlled” and “Is Player Controlled” to stop the user select affecting the NPCs. Also only choose “Client Component” in the components list of the Lyra Experience Definition.

Result is here

2 Likes