BUG: playerarray has invalid playerstates? please help

i switch from ue4.26 to ue5.0 and found out that the playerarray gives me invalid playerstates

image

tested on a new project


ingame prints: “F”

image

To add to this, player states are not being spawned for each player either. Each player only has their own player state.

oh, hope they fix that soon :smiley:

can i report it somewhere else?
i just want to make sure they get the bug report :smiley:

Help > Report a Bug… in the editor will take you to their bug submission page.

I just submitted one for this after testing it some more.

thanks for submitting it and thanks for the link!

I think this is related to TObjectPtr. If you log PlayerArray from C++, it holds pointers to valid PlayerState(s) as expected. If you log PlayerArray from blueprint, its pointers are reported as invalid.

In GameStateBase, PlayerArray is exposed as:

UPROPERTY(Transient, BlueprintReadOnly, Category=GameState)
TArray<TObjectPtr<APlayerState>> PlayerArray;

If you make a helper function that returns TArray<APlayerState*>, it works in blueprints. Ex:

UFUNCTION(BlueprintPure)
TArray<APlayerState*> GetPlayerArray() const;

TArray<APlayerState*> AGame_GameState::GetPlayerArray() const
{
	return PlayerArray;
}

I figured it was just BP having issues with the TObjectPtr changes somehow. I tried the main branch and it seems to already be fixed there. I don’t know from what though because there’s quite a lot of changes between the two.

I’m still seeing this behavior almost a month later on EU5 EA2.

I wish I had found this thread sooner as I spent a long time thinking I was doing something wrong. Eventually I tested and it works great in UE4, but not in 5.

1 Like

Hi there,

I’ve also been sitting on the problem for a while before I found the thread here.

I’ve been testing for a day how to create a helper function.
For this I have changed my project to C++, I can now create a C++ classe.
I’ve created a C++ GameStateBase and I’m also finding the code.

But I’ve never worked with C++, until now I’ve only ever worked with blueprints.

I wonder if I’m really on the right track, because I can’t edit a C++ classe as a blueprint. Can someone send me a screenshot where I can see a bit more?

BR

i hope they fix that soon

i tried adding it to the bugreport (Unreal Engine Community)
but if i then search for the bug, it dont appear there, really strange, like it never reached there

maybe there is a newer page somewhere??

1 Like

I found this fix posted on reddit, and it worked.

Please find the bug you posted, or repost and update this entry with the link so we can upvote it.

1 Like

This seems to be corrected on the 5.0 release branch (that had appeared few days ago on github), I’ve compiled the engine and no more error!

1 Like

does it work with 5.0.2?