사용자 지정 플레이어 컨트롤러
This commit is contained in:
parent
0ff8baf48f
commit
bf043b91fd
BIN
Content/Blueprints/Controller/BP_ToonTanksPlayerController.uasset
(Stored with Git LFS)
Normal file
BIN
Content/Blueprints/Controller/BP_ToonTanksPlayerController.uasset
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Content/Blueprints/GameMode/BP_ToonTanksGameMode.uasset
(Stored with Git LFS)
BIN
Content/Blueprints/GameMode/BP_ToonTanksGameMode.uasset
(Stored with Git LFS)
Binary file not shown.
@ -3,6 +3,7 @@
|
||||
|
||||
#include "Tank.h"
|
||||
|
||||
#include "ToonTanksPlayerController.h"
|
||||
#include "Camera/CameraComponent.h"
|
||||
#include "GameFramework/SpringArmComponent.h"
|
||||
#include "Kismet/GameplayStatics.h"
|
||||
@ -37,13 +38,6 @@ void ATank::Tick(float DeltaTime)
|
||||
false,
|
||||
HitResult
|
||||
);
|
||||
DrawDebugSphere(
|
||||
GetWorld(),
|
||||
HitResult.ImpactPoint,
|
||||
25,
|
||||
12,
|
||||
FColor::Green
|
||||
);
|
||||
RotateTurret(HitResult.ImpactPoint);
|
||||
}
|
||||
}
|
||||
|
@ -3,6 +3,7 @@
|
||||
|
||||
#include "ToonTanksGameMode.h"
|
||||
#include "Tank.h"
|
||||
#include "ToonTanksPlayerController.h"
|
||||
#include "Tower.h"
|
||||
#include "Kismet/GameplayStatics.h"
|
||||
|
||||
@ -10,6 +11,7 @@ void AToonTanksGameMode::BeginPlay()
|
||||
{
|
||||
Super::BeginPlay();
|
||||
Tank = Cast<ATank>(UGameplayStatics::GetPlayerPawn(this, 0));
|
||||
PlayerController = Cast<AToonTanksPlayerController>(UGameplayStatics::GetPlayerController(this, 0));
|
||||
}
|
||||
|
||||
void AToonTanksGameMode::ActorDied(AActor* DeadActor)
|
||||
@ -17,10 +19,9 @@ void AToonTanksGameMode::ActorDied(AActor* DeadActor)
|
||||
if (DeadActor == Tank)
|
||||
{
|
||||
Tank->HandleDestruction();
|
||||
if (Tank->GetPlayerController())
|
||||
if (PlayerController)
|
||||
{
|
||||
Tank->DisableInput(Tank->GetPlayerController());
|
||||
Tank->GetPlayerController()->bShowMouseCursor = false;
|
||||
PlayerController->SetPlayerEnabledState(false);
|
||||
}
|
||||
}
|
||||
else if (ATower* DestroyedTower = Cast<ATower>(DeadActor))
|
||||
|
@ -25,5 +25,9 @@ private:
|
||||
// Tank Pointer for DeadActor which is ATank.
|
||||
UPROPERTY()
|
||||
class ATank* Tank;
|
||||
|
||||
// ToonTanksPlayerController Pointer of player pawn.
|
||||
UPROPERTY()
|
||||
class AToonTanksPlayerController* PlayerController;
|
||||
|
||||
};
|
||||
|
17
Source/ToonTanks/ToonTanksPlayerController.cpp
Normal file
17
Source/ToonTanks/ToonTanksPlayerController.cpp
Normal file
@ -0,0 +1,17 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
|
||||
#include "ToonTanksPlayerController.h"
|
||||
|
||||
void AToonTanksPlayerController::SetPlayerEnabledState(bool bPlayerEnabled)
|
||||
{
|
||||
if (bPlayerEnabled)
|
||||
{
|
||||
GetPawn()->EnableInput(this);
|
||||
}
|
||||
else
|
||||
{
|
||||
GetPawn()->DisableInput(this);
|
||||
}
|
||||
bShowMouseCursor = bPlayerEnabled;
|
||||
}
|
21
Source/ToonTanks/ToonTanksPlayerController.h
Normal file
21
Source/ToonTanks/ToonTanksPlayerController.h
Normal file
@ -0,0 +1,21 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "GameFramework/PlayerController.h"
|
||||
#include "ToonTanksPlayerController.generated.h"
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
UCLASS()
|
||||
class TOONTANKS_API AToonTanksPlayerController : public APlayerController
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
// Set this controller to Enabled or Disabled.
|
||||
void SetPlayerEnabledState(bool bPlayerEnabled);
|
||||
|
||||
};
|
Loading…
x
Reference in New Issue
Block a user