Not sure what I did wrong. It feels like the include isn’t actually working properlty or maybe I am missing the correct include.
Anyone have an idea what is wrong??? Both of the objects should have identifiers since they are being declared.
When I compile I keep getting an error about:
// Fill out your copyright notice in the Description page of Project Settings.
#include "PawnTurret.h"
#include "Kismet/GameplayStatics.h"
#include "PawnTank.h"
// Called when the game starts or when spawned
void APawnTurret::BeginPlay()
{
Super::BeginPlay();
GetWorld()->GetTimerManager().SetTimer(FireRateTimerHandle, this, &APawnTurret::CheckFireCondition, FireRate, true);
PlayerPawn = Cast<APawnTank>(UGameplayStatics::GetPlayerPawn(this, 0));
}
void APawnTurret::HandleDestruction()
{
Super::HandleDestruction();
Destroy();
}
// Called every frame
void APawnTurret::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);
if(!PlayerPawn || ReturnDistanceToPlayer() < FireRange)
{
RotateTurret(PlayerPawn->GetActorLocation());
}
}
void APawnTurret::CheckFireCondition()
{
// if the player is null || is Dea then bail!!
// if the play is in range then fire.
if (!PlayerPawn)
{
return;
}
if(ReturnDistanceToPlayer()<= FireRange)
{
Fire();
}
}
float APawnTurret::ReturnDistanceToPlayer()
{
if (!PlayerPawn)
{
return 0.0f;
}
// two ways of writing the below code
// return FVector::Dist(PlayerPawn->GetActorLocation(),GetActorLocation());
// or the below. I opted for the below because it is a bit easier to read but both do the same thing.
float Distance = FVector::Dist(PlayerPawn->GetActorLocation(),GetActorLocation());
return Distance;
}