Identifying player, local multiplayer

#Player State

In the player state class there is a unique ID value that will help you

/** Unique id number. */
UPROPERTY(replicated)
int32 PlayerId;

#Controller ID

The controller ID is not part of UPlayer, it is in ULocalPlayer

so you must obtain a ULocalPlayer in order to access this value

It can be accessed from the Player Controller Class!

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//		   Get Local Player Controller ID
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~
int32 AVictoryGameSession::GetLocalPlayerControllerId(APlayerController* PC)
{
	check(PC);
	
	ULocalPlayer * LP = Cast<ULocalPlayer>(PC->Player);
	if(!LP) return -1;
	
	return LP->ControllerId;
}

If you cannot find anyway to do this in BP (if you need to do it there), let me know and I can make a node for it

:slight_smile:

Rama

1 Like