FDamageEvent cannot convert to incomplete class | TakeDamage c++

Hello everyone! Can you help me with the problem. I use the C++ interface and call a number of functions on behalf of the character from all Actors who have such an interface. According to the task, I have to call the damage function for actors from them. I just have to have different damage values and that’s it. I’m trying to use TakeDamage, but he needs a special event so that he understands what type I’m probably using. I have an error on FDamageEvent ToDamageEvent

“cannot convert to incomplete class FDamageEvent”

In the task, I should not use anything other than the damage call function. Line Tracing cannot be used. I just have to make a massive appeal to all the actors and call them functions that cause damage.

I started learning C++ for Unreal Engine at the beginning of this year, so the question may seem very stupid.

// Actor_One.h file
#include "CoreMinimal.h"
#include "GameFramework/Actor.h"
#include "MyInterface.h"
#include "Actor_One.generated.h"

UCLASS()
class THIRDPERSONMP_API AActor_One : public AActor, public IMyInterface
{
	GENERATED_BODY()
	
public:	
	// Sets default values for this actor's properties
	AActor_One();

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

	virtual float TakeDamage(float DamageAmount, struct FDamageEvent const& DamageEvent, class AController* EventInstigator, AActor* DamageCauser) override;

public:	
	// Called every frame
	virtual void Tick(float DeltaTime) override;

	// Interface system

	UFUNCTION(BlueprintCallable, BlueprintNativeEvent, Category = "Gameplay")
		void SmallHitInteract();

	UFUNCTION(BlueprintCallable, BlueprintNativeEvent, Category = "Gameplay")
		void BigHitInteract();

	void SmallHitInteract_Implementation() override;

	void BigHitInteract_Implementation() override;

};

// Actor_One.cpp file
#include "Actor_One.h"
#include "Engine/EngineTypes.h"

// Sets default values
AActor_One::AActor_One()
{
 	// Set this actor to call Tick() every frame.  You can turn this off to improve performance if you don't need it.
	PrimaryActorTick.bCanEverTick = true;

}

// Called when the game starts or when spawned
void AActor_One::BeginPlay()
{
	Super::BeginPlay();
	
}

float AActor_One::TakeDamage(float DamageAmount, FDamageEvent const& DamageEvent, AController* EventInstigator, AActor* DamageCauser)
{
	return Super::TakeDamage(DamageAmount, DamageEvent, EventInstigator, DamageCauser);
}

// Called every frame
void AActor_One::Tick(float DeltaTime)
{
	Super::Tick(DeltaTime);

}

void AActor_One::SmallHitInteract_Implementation()
{
	AActor* Owner = GetOwner();
	float Damage = 10.0f;

	if (Owner) {
		FDamageEvent ToDamageEvent();
		Owner->TakeDamage(Damage, ToDamageEvent, GetOwner()->GetInstigatorController(), this);
	}
}

void AActor_One::BigHitInteract_Implementation()
{
	AActor* Owner = GetOwner();
	float Damage = 20.0f;

	if (Owner) {

	}
}
Owner->TakeDamage(Damage, FDamageEvent(), GetOwner()->GetInstigatorController(), this);

Errors:

use of undefined type ‘FDamageEvent’ | C2027

AActor::TakeDamage’: function does not take 3 arguments | C2660

I have also found such a way here: UGameplayStatics::ApplyDamage(MyActor, Damage, GetOwner()->GetInstigatorController(), this, UDamageType::StaticClass()); but nothing happens to me. Perhaps I should describe in a separate TakeDamage function what should be happening. I have a health component, where there is a variable HP, which changes if any damage is done to the character (of course, if the component is attached). I have now tried different ways. Using blueprint, I output any damage at AnyDamage. It turns out I’m just not doing any damage to the character. I don’t understand what I’m doing wrong.

Answer: c++17 - FPointDamageEvent error "incomplete type is not allowed" (Unreal Engine 5.1) - Stack Overflow

For UE5.1 I also need to #include "Engine/DamageEvents.h"

1 Like