Download

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.