From 8e1f1c0e2a6eb896bd01f6b3ecb53085ac4d5934 Mon Sep 17 00:00:00 2001 From: 10000Je Date: Thu, 24 Apr 2025 20:39:01 +0900 Subject: [PATCH] =?UTF-8?q?=EC=BA=90=EC=8A=A4=ED=8C=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Source/ToonTanks/BasePawn.cpp | 7 ------- Source/ToonTanks/BasePawn.h | 4 ---- Source/ToonTanks/Tank.cpp | 8 ++++++++ Source/ToonTanks/Tank.h | 6 ++++++ 4 files changed, 14 insertions(+), 11 deletions(-) diff --git a/Source/ToonTanks/BasePawn.cpp b/Source/ToonTanks/BasePawn.cpp index 52e091e..50b9f86 100644 --- a/Source/ToonTanks/BasePawn.cpp +++ b/Source/ToonTanks/BasePawn.cpp @@ -24,13 +24,6 @@ ABasePawn::ABasePawn() ProjectileSpawnPoint->SetupAttachment(TurretMesh); } -// Called when the game starts or when spawned -void ABasePawn::BeginPlay() -{ - Super::BeginPlay(); - -} - // Called every frame void ABasePawn::Tick(float DeltaTime) { diff --git a/Source/ToonTanks/BasePawn.h b/Source/ToonTanks/BasePawn.h index 9e3673d..fade659 100644 --- a/Source/ToonTanks/BasePawn.h +++ b/Source/ToonTanks/BasePawn.h @@ -15,10 +15,6 @@ public: // Sets default values for this pawn's properties ABasePawn(); -protected: - // Called when the game starts or when spawned - virtual void BeginPlay() override; - private: UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Component", meta=(AllowPrivateAccess = "true")) class UCapsuleComponent* CapsuleComp; diff --git a/Source/ToonTanks/Tank.cpp b/Source/ToonTanks/Tank.cpp index f38e686..15ef830 100644 --- a/Source/ToonTanks/Tank.cpp +++ b/Source/ToonTanks/Tank.cpp @@ -23,6 +23,14 @@ void ATank::SetupPlayerInputComponent(UInputComponent* PlayerInputComponent) PlayerInputComponent->BindAxis(TEXT("Turn"), this, &ATank::Turn); } +// Called when the game starts or when spawned +void ATank::BeginPlay() +{ + Super::BeginPlay(); + + PlayerControllerRef = Cast(GetController()); +} + void ATank::Move(float Value) { FVector DeltaLocation = FVector::ZeroVector; diff --git a/Source/ToonTanks/Tank.h b/Source/ToonTanks/Tank.h index 454b7dd..1151de5 100644 --- a/Source/ToonTanks/Tank.h +++ b/Source/ToonTanks/Tank.h @@ -19,6 +19,10 @@ public: // Called to bind functionality to input virtual void SetupPlayerInputComponent(class UInputComponent* PlayerInputComponent) override; + +protected: + // Called when the game starts or when spawned + virtual void BeginPlay() override; private: UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Component", meta=(AllowPrivateAccess = "true")) @@ -32,6 +36,8 @@ private: UPROPERTY(EditAnywhere, Category = "Movement") float TurnRate = 45.0f; + + APlayerController* PlayerControllerRef; void Move(float Value);