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);