Hi I keep getting this compile error after I added particle effects to the PawnBase Parent Class. I dont quite understand what is wrong. My Code for PawnBase and the headers for the PawnTank and PawnTurret are included below.
// Fill out your copyright notice in the Description page of Project Settings.
#include "PawnBase.h"
// Sets default values
APawnBase::APawnBase()
{
// Set this pawn to call Tick() every frame. You can turn this off to improve performance if you don't need it.
PrimaryActorTick.bCanEverTick = true;
CapsuleComp = CreateDefaultSubobject<UCapsuleComponent>(TEXT("Capsule Collider"));
RootComponent = CapsuleComp;
BaseMesh = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("Base Mesh"));
BaseMesh->SetupAttachment(RootComponent);
TurretMesh = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("Turret Mesh"));
TurretMesh->SetupAttachment(BaseMesh);
ProjectileSpawnPoint = CreateDefaultSubobject<USceneComponent>(TEXT("Projectile Spawn Point"));
ProjectileSpawnPoint->SetupAttachment(TurretMesh);
HealthComponent = CreateDefaultSubobject<UHealthComponent>(TEXT("Health Component"));
}
void APawnBase::RotateTurret(FVector LookAtTarget)
{
FVector LookAtTargetCleaned = FVector(LookAtTarget.X, LookAtTarget.Y, TurretMesh->GetComponentLocation().Z);
FVector StartLocation = TurretMesh->GetComponentLocation();
FRotator TurretRotation = FVector(LookAtTargetCleaned - StartLocation).Rotation();
TurretMesh->SetWorldRotation(TurretRotation);
}
void APawnBase::Fire()
{
if(ProjectileClass)
{
FVector SpawnLocation = ProjectileSpawnPoint->GetComponentLocation();
FRotator SpawnRotation = ProjectileSpawnPoint->GetComponentRotation();
AProjectileBase* TempProjectile = GetWorld()->SpawnActor<AProjectileBase>(ProjectileClass, SpawnLocation, SpawnRotation);
TempProjectile->SetOwner(this);
}
}
void APawnBase::HandleDestruction()
{
// Universal Functionality
//Play death effects particle , sound and camera shake
UGameplayStatics::SpawnEmitterAtLocation(this, DeathParticle, GetActorLocation());
//Then do child overrides
// PawnTurret Inform GameMode Turret died -> then Destroy() self
//PawnTank inform GameMode Player died -> then Hide() all components && stop movement input
}
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "GameFramework/Pawn.h"
#include "Components/SceneComponent.h"
#include "Components/CapsuleComponent.h"
#include "Components/StaticMeshComponent.h"
#include "Particles/ParticleSystem.h"
#include "Kismet/GameplayStatics.h"
#include "ToonTanks/Components/HealthComponent.h"
#include "ToonTanks/Actors/ProjectileBase.h"
#include "PawnBase.generated.h"
class UCapsuleComponent;
class AProjectileBase;
class UHealthComponent;
UCLASS()
class TOONTANKS_API APawnBase : public APawn
{
GENERATED_BODY()
private:
//Components
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Components", meta = (AllowPrivateAccess = "true"))
UCapsuleComponent* CapsuleComp;
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Components", meta = (AllowPrivateAccess = "true"))
UStaticMeshComponent* BaseMesh;
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Components", meta = (AllowPrivateAccess = "true"))
UStaticMeshComponent* TurretMesh;
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Components", meta = (AllowPrivateAccess = "true"))
USceneComponent* ProjectileSpawnPoint;
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Components", meta = (AllowPrivateAccess = "true"))
UHealthComponent* HealthComponent;
//Variables
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Projectile Type", meta = (AllowPrivateAccess = "true"))
TSubclassOf<AProjectileBase> ProjectileClass;
UPROPERTY(EditAnywhere, Category = "Effects")
UParticleSystem* DeathParticle;
public:
// Sets default values for this pawn's properties
APawnBase();
virtual void HandleDestruction();
protected:
void RotateTurret(FVector LookAtTarget);
void Fire();
};
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "Pawns/PawnBase.h"
#include "Camera/CameraComponent.h"
#include "GameFramework/SpringArmComponent.h"
#include "GameFramework/Actor.h"
#include "GameFramework/PlayerController.h"
#include "Components/InputComponent.h"
#include "Math/Rotator.h"
#include "PawnTank.generated.h"
class USpringArmComponent;
class UCameraComponent;
class UHealthComponent;
class APawnBase;
UCLASS()
class TOONTANKS_API APawnTank : public APawnBase
{
GENERATED_BODY()
private:
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Components", meta = (AllowPrivateAccess = "true"))
UCameraComponent* Camera;
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Components", meta = (AllowPrivateAccess = "true"))
USpringArmComponent* SpringArm;
FVector MoveDirection;
FQuat RotationDirection;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Movement", meta = (AllowPrivateAccess = "true"))
float MoveSpeed = 500.0f;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Movement", meta = (AllowPrivateAccess = "true"))
float RotateSpeed = 250.0f;
APlayerController* PlayerControllerRef;
void CalculateMoveInput(float Value);
void CalculateRotateInput(float Value);
void Move();
void Rotate();
bool bIsPlayerAlive = true;
public:
APawnTank();
// Called to bind functionality to input
virtual void SetupPlayerInputComponent(class UInputComponent* PlayerInputComponent) override;
// Called every frame
virtual void Tick(float DeltaTime) override;
virtual void HandleDestruction() override;
bool GetIsPlayerAlive();
protected:
virtual void BeginPlay() override;
};
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "Pawns/PawnBase.h"
#include "Pawns/PawnTank.h"
#include "Engine/EngineTypes.h"
#include "Kismet/GameplayStatics.h"
#include "TimerManager.h"
#include "Engine/World.h"
#include "PawnTurret.generated.h"
class APawnTank;
class UHealthComponent;
class APawnBase;
UCLASS()
class TOONTANKS_API APawnTurret : public APawnBase
{
GENERATED_BODY()
private:
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Combat", meta = (AllowPrivateAccess = "true"))
float FireRate = 2.0f;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Combat", meta = (AllowPrivateAccess = "true"))
float FireRange = 500.0f;
FTimerHandle FireRateTimerHandle;
APawnTank* PlayerPawn;
void CheckFireCondition();
float ReturnDistanceToPlayer();
public:
// Called every frame
virtual void Tick(float DeltaTime) override;
virtual void HandleDestruction() override;
protected:
// Called when the game starts or when spawned
virtual void BeginPlay() override;
};