dealt with problem of Play as client mode

pull/6/head
m4xxx1m 2 years ago
parent c256136d69
commit fd6ead7f42

@ -0,0 +1,13 @@
// Fill out your copyright notice in the Description page of Project Settings.
#include "MainMenuPlayerController.h"
#include "Blueprint/UserWidget.h"
void AMainMenuPlayerController::BeginPlay() {
Super::BeginPlay();
SetShowMouseCursor(true);
UUserWidget *CreatedWidget = CreateWidget<UUserWidget>(
GetWorld(), WidgetClass);
CreatedWidget->AddToViewport();
}

@ -0,0 +1,22 @@
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "GameFramework/PlayerController.h"
#include "MainMenuPlayerController.generated.h"
/**
*
*/
UCLASS()
class TURNBASEDTUTORIAL_API
AMainMenuPlayerController : public APlayerController {
GENERATED_BODY()
virtual void BeginPlay() override;
protected:
UPROPERTY(EditAnywhere)
TSubclassOf<UUserWidget> WidgetClass;
};

@ -5,6 +5,7 @@
#include "MyGameMode.h"
#include "MyGameState.h"
#include "MyPlayerState.h"
#include "Blueprint/UserWidget.h"
#include "Net/UnrealNetwork.h"
AMyPlayerController::AMyPlayerController()
@ -13,6 +14,13 @@ AMyPlayerController::AMyPlayerController()
SetShowMouseCursor(true);
}
void AMyPlayerController::BeginPlay() {
Super::BeginPlay();
UUserWidget *CreatedWidget = CreateWidget<UUserWidget>(
GetWorld(), WidgetClass);
CreatedWidget->AddToViewport();
}
void AMyPlayerController::SetupInputComponent() {
Super::SetupInputComponent();
InputComponent->BindAction("MyAction", IE_Pressed, this,
@ -129,7 +137,7 @@ void AMyPlayerController::EndTurn_Implementation() {
void AMyPlayerController::SetPlayerIndex(uint8 NewPlayerIndex) {
PlayerIndex = NewPlayerIndex;
GetMyPlayerState()->SetPlayerIndex(NewPlayerIndex);
// GetMyPlayerState()->PlayerIndex = NewPlayerIndex;
}

@ -12,6 +12,8 @@ class TURNBASEDTUTORIAL_API AMyPlayerController : public APlayerController {
GENERATED_BODY()
public:
virtual void BeginPlay() override;
// FOnMyTurnChangedDelegate OnMyTurnChanged;
virtual void SetupInputComponent() override;
@ -49,6 +51,9 @@ public:
// void SetEnemySelection(const TArray<ATrooper *> &Troopers) const;
private:
UPROPERTY(EditAnywhere)
TSubclassOf<UUserWidget> WidgetClass;
// UPROPERTY(Replicated)
// bool bIsMyTurn;
//

Loading…
Cancel
Save