[Lyra] Blueprint child of LyraPlayerState C++ crashes when opening?

You can reproduce this in LyraStarterGame
When you create a blueprint child of LyraPlayerState C++ and open it… boom the crash handler will report this:

line: 150
So I think the issue is here somewhere?
What to do to make it work in child BP?
GAS cannot be handle with a BP playerstate? :thinking:

void ALyraPlayerState::PostInitializeComponents()
{
	Super::PostInitializeComponents();

	check(AbilitySystemComponent);
	AbilitySystemComponent->InitAbilityActorInfo(this, GetPawn());

	if (GetNetMode() != NM_Client)
	{
		AGameStateBase* GameState = GetWorld()->GetGameState();
		check(GameState);
		ULyraExperienceManagerComponent* ExperienceComponent = GameState->FindComponentByClass<ULyraExperienceManagerComponent>();
		check(ExperienceComponent);
		ExperienceComponent->CallOrRegister_OnExperienceLoaded(FOnLyraExperienceLoaded::FDelegate::CreateUObject(this, &ThisClass::OnExperienceLoaded));
	}
}
2 Likes

If anyone else encounters this, it’s because ALyraPlayerState::PostInitializeComponents() doesn’t handle the case of running in the editor properly. I fixed with this:

Others can comment on whether this is a good way to fix it.

4 Likes

It works
Thanks a lot !

1 Like