Errors In Toon Tanks!

Look:
Building ToonTanksEditor…
Using Visual Studio 2022 14.30.30705 toolchain (C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.30.30705) and Windows 10.0.18362.0 SDK (C:\Program Files (x86)\Windows Kits\10).
Building 5 actions with 8 processes…
[1/5] HealthComponent.cpp
C:\Unreal Engine C++ Developer Learn C++ and Make Video Games\ToonTanks\Source\ToonTanks\HealthComponent.cpp(26) : error C2064: term does not evaluate to a function taking 0 arguments
C:\Unreal Engine C++ Developer Learn C++ and Make Video Games\ToonTanks\Source\ToonTanks\HealthComponent.cpp(28) : error C2440: ‘’: cannot convert from ‘AGameModeBase *’ to ‘AToonTanksGameMode’
C:\Unreal Engine C++ Developer Learn C++ and Make Video Games\ToonTanks\Source\ToonTanks\HealthComponent.cpp(28): note: No constructor could take the source type, or constructor overload resolution was ambiguous
C:\Unreal Engine C++ Developer Learn C++ and Make Video Games\ToonTanks\Source\ToonTanks\HealthComponent.cpp(28) : error C2059: syntax error: ‘;’
C:\Unreal Engine C++ Developer Learn C++ and Make Video Games\ToonTanks\Source\ToonTanks\HealthComponent.cpp(29) : error C2143: syntax error: missing ‘;’ before ‘}’
C:\Unreal Engine C++ Developer Learn C++ and Make Video Games\ToonTanks\Source\ToonTanks\HealthComponent.cpp(33) : error C2146: syntax error: missing ‘>’ before identifier ‘ThisTickFunction’
C:\Unreal Engine C++ Developer Learn C++ and Make Video Games\ToonTanks\Source\ToonTanks\HealthComponent.cpp(34) : error C2143: syntax error: missing ‘;’ before ‘{’
C:\Unreal Engine C++ Developer Learn C++ and Make Video Games\ToonTanks\Source\ToonTanks\HealthComponent.cpp(35) : error C2065: ‘TickType’: undeclared identifier
C:\Unreal Engine C++ Developer Learn C++ and Make Video Games\ToonTanks\Source\ToonTanks\HealthComponent.cpp(35) : error C2065: ‘ThisTickFunction’: undeclared identifier
C:\Unreal Engine C++ Developer Learn C++ and Make Video Games\ToonTanks\Source\ToonTanks\HealthComponent.cpp(35) : error C2059: syntax error: ‘)’
C:\Unreal Engine C++ Developer Learn C++ and Make Video Games\ToonTanks\Source\ToonTanks\HealthComponent.cpp(38) : error C2143: syntax error: missing ‘;’ before ‘}’
C:\Unreal Engine C++ Developer Learn C++ and Make Video Games\ToonTanks\Source\ToonTanks\HealthComponent.cpp(40) : error C2146: syntax error: missing ‘>’ before identifier ‘DamageType’
C:\Unreal Engine C++ Developer Learn C++ and Make Video Games\ToonTanks\Source\ToonTanks\HealthComponent.cpp(40) : error C2146: syntax error: missing ‘>’ before identifier ‘Instigator’
C:\Unreal Engine C++ Developer Learn C++ and Make Video Games\ToonTanks\Source\ToonTanks\HealthComponent.cpp(40) : error C2146: syntax error: missing ‘>’ before identifier ‘DamageCauser’
C:\Unreal Engine C++ Developer Learn C++ and Make Video Games\ToonTanks\Source\ToonTanks\HealthComponent.cpp(41) : error C2143: syntax error: missing ‘;’ before ‘{’
C:\Unreal Engine C++ Developer Learn C++ and Make Video Games\ToonTanks\Source\ToonTanks\HealthComponent.cpp(42) : error C2947: expecting ‘>’ to terminate template-argument-list, found ‘<=’
C:\Unreal Engine C++ Developer Learn C++ and Make Video Games\ToonTanks\Source\ToonTanks\HealthComponent.cpp(42) : error C2062: type ‘unknown-type’ unexpected
C:\Unreal Engine C++ Developer Learn C++ and Make Video Games\ToonTanks\Source\ToonTanks\HealthComponent.cpp(42) : error C2059: syntax error: ‘)’
C:\Unreal Engine C++ Developer Learn C++ and Make Video Games\ToonTanks\Source\ToonTanks\HealthComponent.cpp(48) : error C2065: ‘DamagedActor’: undeclared identifier
[2/5] ToonTanksGameMode.cpp
C:\Unreal Engine C++ Developer Learn C++ and Make Video Games\ToonTanks\Source\ToonTanks\ToonTanksGameMode.cpp(11) : error C2065: ‘DeadActor’: undeclared identifier
C:\Unreal Engine C++ Developer Learn C++ and Make Video Games\ToonTanks\Source\ToonTanks\ToonTanksGameMode.cpp(18) : error C2039: ‘GetPlayerController’: is not a member of ‘ATank’
C:\Unreal Engine C++ Developer Learn C++ and Make Video Games\ToonTanks\Source\ToonTanks\Tank.h(13): note: see declaration of ‘ATank’
C:\Unreal Engine C++ Developer Learn C++ and Make Video Games\ToonTanks\Source\ToonTanks\ToonTanksGameMode.cpp(22) : error C2065: ‘DeadActor’: undeclared identifier
Look:
HealthComponent.h

// Fill out your copyright notice in the Description page of Project Settings.

#pragma once

#include "CoreMinimal.h"
#include "Components/ActorComponent.h"
#include "HealthComponent.generated.h"


UCLASS( ClassGroup=(Custom), meta=(BlueprintSpawnableComponent) )
class TOONTANKS_API UHealthComponent : public UActorComponent
{
	GENERATED_BODY()

public:	
	// Sets default values for this component's properties
	UHealthComponent();

protected:
	// Called when the game starts
	virtual void BeginPlay() override;

private:
	UPROPERTY(EditAnywhere)
	float MaxHealth = 100.f;
	float Health = 0.f;

	UFUNCTION()
	void DamageTaken(AActor* DamagedActor, float Damage, UDamageType* DamageType, class AController* Instigator, AActor* DamageCauser);

	class AToonTanksGameMode* ToonTanksGameMode;

public:	
	// Called every frame
	virtual void TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) override;

};

HealthComponent.cpp:

// Fill out your copyright notice in the Description page of Project Settings.


#include "HealthComponent.h"
#include "Kismet/GameplayStatics.h"
#include "ToonTanksGameMode.h"

// Sets default values for this component's properties
UHealthComponent::UHealthComponent()
{
	// Set this component to be initialized when the game starts, and to be ticked every frame.  You can turn these features
	// off to improve performance if you don't need them.
	PrimaryComponentTick.bCanEverTick = true;

	// ...
}


// Called when the game starts
void UHealthComponent::BeginPlay()
{
	Super::BeginPlay();

	Health = MaxHealth;
	
	GetOwner()->OnTakeAnyDamage().AddDynamic(this, &UHealthComponent::DamageTaken);

	ToonTanksGameMode = Cast<AToonTanksGameMode(UGameplayStatics::GetGameMode(this));
}


// Called every frame
void UHealthComponent::TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction)
{
	Super::TickComponent(DeltaTime, TickType, ThisTickFunction);

	// ...
}

void UHealthComponent::DamageTaken(AActor* DamagedActor, float Damage, UDamageType* DamageType, AController* Instigator, AActor* DamageCauser)
{
	if (Damage <= 0.f) return

	Health -= Damage;

	if (Health <= 0.f && ToonTanksGameMode)
	{
		ToonTanksGameMode->ActorDied(DamagedActor);
	}
}

ToonTanksGameMode.h:

// Fill out your copyright notice in the Description page of Project Settings.

#pragma once

#include "CoreMinimal.h"
#include "GameFramework/GameModeBase.h"
#include "ToonTanksGameMode.generated.h"

/**
 * 
 */
UCLASS()
class TOONTANKS_API AToonTanksGameMode : public AGameModeBase
{
	GENERATED_BODY()

public:
	void ActorDied(AActor* DeadActor);

protected:
	virtual void BeginPlay() override;
	
private:
	class ATank* Tank;
};

ToonTanksGameMode.cpp:

// Fill out your copyright notice in the Description page of Project Settings.


#include "ToonTanksGameMode.h"
#include "Kismet/GameplayStatics.h"
#include "Tank.h"
#include "Tower.h"

void AToonTanksGameMode::ActorDied(AActor* ActorDied)
{
    if (DeadActor == Tank)
    {
        Tank->HandleDestruction();

        if (Tank->GetTankPlayerController())
        {
            Tank->DisableInput(Tank->GetTankPlayerController());
            Tank->GetPlayerController()->bShowMouseCursor = false;
        }
    }

    else if (ATower* DestroyedTower = Cast<ATower>(DeadActor))
    {
        DestroyedTower->HandleDestruction();
    }
}

void AToonTanksGameMode::BeginPlay()
{
    Super::BeginPlay();

    Tank = Cast<ATank>(UGameplayStatics::GetPlayerPawn(this, 0));
}

Please help!

@Morderkainer
@DanM
How do I fix the errors?

@Morderkainer
@DanM
How do I fix the errors? Please help; I am waiting for a long time.

Please just update your thread. There’s no reason to create a new thread. Also see about my comment about being patient.

A post was merged into an existing topic: Errors In Toon Tanks

Privacy & Terms