// Get the name of the player string playerName = Player.GetName(); // Output the player name to the console cout << "Player name: " << playerName << endl;
// Get a reference to the player APlayerController* playerController = GetWorld()->GetFirstPlayerController(); AActor* playerActor = playerController->GetPawn(); IOnlineIdentityPtr onlineIdentity = Online::GetIdentityInterface(); IOnlineSubsystem* onlineSubsystem = onlineIdentity->GetSubsystem(); // Get the name of the player FString playerName = onlineSubsystem->GetIdentityInterface()->GetPlayerNickname(0); // Output the player name to the console UE_LOG(LogTemp, Warning, TEXT("Player name: %s"), *playerName);This example uses several functions to get a reference to the player and then retrieves the player's name. The package library used here is Unreal. In both of these examples, Player GetName is used to retrieve the name of the player and then that name is output to the console using different methods. The package libraries used vary depending on the game engine.