TakeDamage Error


I have this error.

My header file

#pragma once

#include “CoreMinimal.h”
#include “GameFramework/Actor.h”
#include “Tank.generated.h”

UCLASS()
class BATTLETANK_API ATank : public APawn
{
GENERATED_BODY()
protected:
virtual void BeginPlay() override;

private:
ATank();
UFUNCTION()
virtual float TakeDamage(float DamageAmount, struct FDamageEvent const& DamageEvent, AController* EventInstigator, AActor* DamageCauser) override;
UPROPERTY(EditDefaultsOnly, Category = “Setup”)
int32 CurrentHealth = 100;
};

And your cpp? By the looks of the error you didn’t define TakeDamage.

#include “Tank.h”
#include “GameFramework/Actor.h”

ATank::ATank()
{
PrimaryActorTick.bCanEverTick = false;
}

void ATank::BeginPlay()
{
Super::BeginPlay();
}

float TakeDamage(float DamageAmount, struct FDamageEvent const& DamageEvent, AController* EventInstigator, AActor* DamageCauser)
{

return 3.f;

}

That’s defining a non-member function as you’re missing the class scope.

Ooops. Thank you, so stupid mistake)

1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms