41 - Optional Challenge: Show the Player Name
This commit is contained in:
parent
86ff124ae4
commit
b4d4ecb47e
Binary file not shown.
|
@ -4,6 +4,7 @@
|
||||||
#include "OverheadWidget.h"
|
#include "OverheadWidget.h"
|
||||||
|
|
||||||
#include "Components/TextBlock.h"
|
#include "Components/TextBlock.h"
|
||||||
|
#include "GameFramework/PlayerState.h"
|
||||||
|
|
||||||
void UOverheadWidget::SetDisplayText(FString TextToDisplay)
|
void UOverheadWidget::SetDisplayText(FString TextToDisplay)
|
||||||
{
|
{
|
||||||
|
@ -37,6 +38,17 @@ void UOverheadWidget::ShowPlayerNetRole(APawn* InPawn)
|
||||||
SetDisplayText(RemoteRoleString);
|
SetDisplayText(RemoteRoleString);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void UOverheadWidget::ShowPlayerName(APawn* InPawn)
|
||||||
|
{
|
||||||
|
if (APlayerState* PlayerState = InPawn->GetPlayerState())
|
||||||
|
{
|
||||||
|
SetDisplayText(PlayerState->GetPlayerName());
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
SetDisplayText("No PlayerState");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void UOverheadWidget::OnLevelRemovedFromWorld(ULevel* InLevel, UWorld* InWorld)
|
void UOverheadWidget::OnLevelRemovedFromWorld(ULevel* InLevel, UWorld* InWorld)
|
||||||
{
|
{
|
||||||
RemoveFromParent();
|
RemoveFromParent();
|
||||||
|
|
|
@ -23,6 +23,9 @@ public:
|
||||||
|
|
||||||
UFUNCTION(BlueprintCallable)
|
UFUNCTION(BlueprintCallable)
|
||||||
void ShowPlayerNetRole(APawn* InPawn);
|
void ShowPlayerNetRole(APawn* InPawn);
|
||||||
|
|
||||||
|
UFUNCTION(BlueprintCallable)
|
||||||
|
void ShowPlayerName(APawn* InPawn);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue